0–5 分钟:映射 listeners
列出 IPv4/IPv6 sockets、protocols、bind addresses、published ports、intended clients 与 owners。
成功标准每个 listener 都有 explicit purpose 与 expected reachability。
本地服务安全检查表 · 更新 2026-07-05
面向 desktop apps、agent tools、self-hosted utilities 与 container-backed local APIs 的实用安全检查表,覆盖本机 HTTP/WebSocket services。
Local services 常因为运行在 developer machine 上而被过度信任,这个假设并不安全。Browser tab、malicious extension、compromised desktop renderer、其他 local process、container、LAN peer,或错误 port publication 都可能在不同 binding、authentication、browser policy 与 network configuration 下访问本地 HTTP/WebSocket endpoint。
这份 checklist 把 Docker Desktop、Podman、Colima、Apple container、Tauri、Electron 与 DeerFlow 连成一个 local-service threat model:窄 bind、认证 privileged operations、验证 browser origins、单独保护 WebSocket handshake/messages、盘点 published ports、把 discovery 与 authorization 分离、限制 container/host access、清理 service state,并保留足够 incident evidence。
RepoDaily 判断
不要把 loopback 当 authentication,也不要把 CORS 当 authorization。Production-quality local service 应具备 explicit bind policy、在存在 privilege 时使用 per-client/per-session authentication、对 browser-facing flow 做 strict origin validation、单独的 WebSocket controls、narrow APIs、bounded payloads/rate limits、确定性的 startup/shutdown、port/endpoint inventory、container publication review,以及不会泄露 secrets 的 incident logs。
| 表面 | 基线规则 | 失败信号 | 保留证据 |
|---|---|---|---|
| Bind address | 只绑定 use case 需要的 interfaces | Local-only service 默认 0.0.0.0 或 [::] | Configured address、actual sockets、owner |
| Authentication | 即使 localhost 也认证 privileged calls | 只要网络可达就能执行操作 | Auth method、token scope、rotation path |
| CORS | Browser clients 使用 exact origin allowlist | Wildcard origin 或 reflected Origin + credentials | Allowed origins 与 negative tests |
| Origin validation | Browser/WebSocket handshake 验证完整 scheme/host/port | Substring matching 或无 Origin check | Origin policy 与 rejection logs |
| WebSockets | 认证 handshake/session 并验证每条 message | Socket 建立后无 message authorization | Handshake checks、message schema、max payload |
| Port publication | 仅发布 required ports 并窄绑定 | Container port 意外对 LAN 可达 | Port inventory 与 network scan result |
| Port discovery | Discovery 只说明位置,不代表 authority | 找到 port 就能控制 service | Discovery mechanism 与 auth boundary |
| API surface | 暴露 narrow task operations | Generic shell/filesystem/SQL/proxy/arbitrary fetch | Endpoint inventory 与 denied tests |
| Lifecycle | 按需 start、可预测 stop、清理 credentials/temp state | Zombie service 或 stale token 在 app exit 后继续有效 | PID/session owner、shutdown test、cleanup proof |
| Logging | 记录 security events 并 redaction | 无 auth failure trace 或 logs 含 token/payload secrets | Event schema、retention、redaction test |
| Containers | Review published ports、mounts、sockets、network reachability | Broad host mount 或 daemon socket 可由 local API 触达 | Runtime config 与 privilege review |
在连接 desktop UI、browser flow、agent runtime 或 container-backed app 前先评分。
| 控制项 | 0 分 | 1 分 | 2 分 | Owner 问题 |
|---|---|---|---|---|
| Network exposure | All interfaces | Loopback configured | Loopback/explicit interface + socket/scan evidence | Host 与 LAN 中谁能访问? |
| Authentication | None | Shared static token | Scoped session/client auth + rotation + expiry | 什么证明 caller 有权? |
| Browser origin policy | Any origin | Manual allowlist | Exact allowlist + tests + separate credential policy | 哪些网站能调用 service? |
| WebSocket security | No checks | Handshake auth only | Origin + auth + per-message authorization + limits | Socket 建立后如何继续授权? |
| API least privilege | Generic powerful API | Some wrappers | Narrow typed operations + validation + denied tests | Client 真正需要的最小 operation 是什么? |
| Container boundary | Broad mounts/socket | Some restrictions | Explicit ports/mounts/networks,无 unnecessary daemon socket | Service compromise 能否变成 host compromise? |
| Lifecycle | Always-on/zombie risk | Manual cleanup | Owned startup/health/shutdown/token invalidation/cleanup | 谁负责 stop 和 reset? |
| Incident evidence | No useful logs | Request logs only | Auth/origin/admin events + correlation IDs + redaction | 能否重建 unauthorized action? |
在 browser、desktop renderer、agent 或 container workflow 接入 local service 前运行。
列出 IPv4/IPv6 sockets、protocols、bind addresses、published ports、intended clients 与 owners。
成功标准每个 listener 都有 explicit purpose 与 expected reachability。
从 host、另一个 local process context 与 LAN peer(适用时)进行 probe。
成功标准Actual exposure 与 documented bind policy 一致。
从 unapproved origin 测试 HTTP、credentialed request、preflight 与 WebSocket handshake rejection。
成功标准Unauthorized origins 不能执行 privileged actions 或建立 trusted sockets。
尝试 missing、expired、wrong-scope、replayed、malformed credentials 与 unauthorized actions。
成功标准Service 在 side effect 前拒绝并记录 usable evidence。
Review mounts、sockets、published ports、arbitrary fetch、shell、filesystem 与 container-control methods。
成功标准不存在不必要的 local API compromise → broad host privilege 路径。
退出 UI、crash/restart service、invalidate tokens,检查 stale sockets、temp state 与 security logs。
成功标准Service 回到 known state,incident evidence 有用且不泄露 secrets。
| 场景 | 必需控制 | 停止条件 |
|---|---|---|
| Desktop app companion API | Loopback、per-session auth、exact renderer origin、narrow methods、app-owned lifecycle | 任意 local webpage/process 可 unauthenticated 调 privileged methods |
| Browser-to-localhost developer tool | Explicit origin allowlist、CSRF-resistant auth、no wildcard credentials、strict scope | Arbitrary website 可触发 local state changes |
| Local WebSocket agent gateway | Origin validation、authenticated handshake、per-message authorization、payload/connection limits | Any origin 可连接或 socket 可执行 unrestricted messages |
| Container-backed local API | Explicit loopback publication、no unnecessary LAN bind、scoped credentials、mount/socket review | Published port 或 daemon socket 暴露 host-level privilege |
| Self-hosted dashboard on LAN | Explicit LAN bind、real user auth、TLS where appropriate、session controls、rate limits、audit events | 把 LAN reachability 当 identity |
| Local model endpoint | Sensitive prompt/data auth、request limits、retention policy、no broad file/tool proxy | Any local process 可 exfiltrate context 或 invoke tools |
| Temporary test server | Random/reserved port、loopback、short lifetime、no prod secrets、deterministic cleanup | Test 后 server 仍存在或 bind all interfaces |
| Agent controlling containers | Narrow broker API、explicit allowed actions、no daemon socket exposure、action logs | Compromised client 可创建 privileged containers 或 arbitrary host mounts |
其他 local processes 与 browser-mediated attacks 仍可能访问 localhost。Loopback 缩小 network exposure,但不认证 caller。
CORS 由 browser 执行,non-browser client 不受其约束;permissive config 还可能暴露 privileged local APIs。
Service 可能保护 HTTP endpoints,却接受任意 origin 的 WebSocket handshake,形成 cross-site request channel。
Container port publication 在未指定窄 host IP 时,可能让 local service 对 localhost 之外的 interface 可达。
Unpredictable port 只能降低 accidental discovery,不能代替 auth,因为 malware、logs、process inspection、browser behavior 或 scans 都可发现。
Arbitrary shell、filesystem、URL、SQL、container operations 或 proxy endpoints 会把小 local service 变成 broad privilege bridge。
Background process、crash recovery、sleep/wake 与 failed shutdown 会让 reachable service/token 在 UI exit 后继续存在。
捕获 Authorization headers、session tokens、prompts、file contents 或 WebSocket payloads 的 debug logs 会形成第二条 data exposure channel。
Loopback 降低 network reachability,独立 authentication mechanism 证明 client authority。
比较完整 normalized origin,包括 scheme、host、port,拒绝 substring/suffix tricks。
使用绑定 service instance、client 或 capability 的短生命周期 token,不使用永久 machine-wide secret。
暴露 startTask、openProject、renderPreview、runApprovedJob,而不是 exec、readAnyFile、proxyUrl 或 raw daemon operations。
维护 machine-readable listeners、protocols、bind addresses、auth requirements、owners 与 intended clients 清单。
让单一 parent process/service manager 负责 startup、health、shutdown、token invalidation 与 cleanup。
记录 auth failures、origin rejects、privileged actions、config changes、restarts、abnormal disconnects,并使用 correlation IDs/redaction。
面向 localhost 与 LAN services 运营团队的简短回答。
不够。它是重要 network boundary,但 privileged operations 仍需要 authorization model,因为其他 local process 与 browser-mediated attack paths 可能访问 localhost。
不能单独做到。CORS 由 browser 强制,不认证 caller。Browser flow 使用 strict origins,同时对 privileged APIs 使用真实 authentication/authorization。
需要。Handshake 验证 Origin、认证 connection、授权 message actions、验证 schemas、限制 payload/rate,并记录 security events。
可以降低 collisions 与 casual discovery,但不应成为主要 auth boundary。Port 可通过 scans、logs、process inspection、browser behavior 或 compromised local software 被发现。
原本只给 host 使用的 service 可能因 publication settings 与 host configuration 对 LAN/其他网络可达,应验证 actual bind scope。
记录 auth failures、rejected origins、privileged operations、config changes、lifecycle events、errors 与 correlation IDs,同时 redaction tokens、secrets 与 sensitive payloads。
Feedback
匿名反馈只用于判断内容是否真正有用。