security: split internal/edge access, harden sandbox, fix follow-up matching

- server: two listeners — :4646 internal (PROXY_INTERNAL_TOKEN only,
  X-Authentik-Username no longer trusted) and :4647 edge (Authentik
  outpost only; requires X-Authentik-Username; NetworkPolicy-restricted)
- session-manager: strip PROXY_INTERNAL_TOKEN & friends from the ACP
  child env (allowlist + proxy vars), dedicated agent HOME, resolved
  tool_call tracking so findSessionForFollowUp ignores already-answered
  results (no more cross-turn log spam / stale matches)
- ask_question auto-answer picks the SAFE option (deny/reject/last),
  never options[0] — root cause of the allow-all config drift
- bootstrap: force-rewrite deny-all cli-config on every boot into BOTH
  proxy and agent HOME (PVC drift self-heals), strip agent-authored hooks
- cli-config: deny all 22 built-in tools (Shell/Read/Write/Grep/Glob/
  WebFetch/WebSearch/Task/...), allow Mcp(*) only
- deploy: edge Service + ServiceExport, NetworkPolicy (4646 open+token,
  4647 only from node2 pod CIDR), readOnlyRootFilesystem, no SA token,
  agent-home + tmp emptyDirs
- Dockerfile: pin cursor-agent 2026.10.22-27dcf5f from build cache (deny
  enforcement verified), non-root, dedicated agent home
- e2e: auth-surface matrix + built-in Read leak check + bridge egress

Closes infra-yip
This commit is contained in:
Ubuntu
2026-10-23 10:11:39 +00:00
parent 71f95e7a0c
commit c0d758249c
11 changed files with 494 additions and 65 deletions
+16 -2
View File
@@ -2,9 +2,23 @@
# Container entrypoint: run cursor-agent bootstrap, then start the proxy.
set -euo pipefail
# Seed ~/.cursor/cli-config.json (default global permissions) and verify
# the cursor-agent binary responds.
# Enforce the sandbox cli-config (force-rewrites runtime/PVC drift back to
# the deny-all policy on every boot) and verify the cursor-agent binary.
/app/scripts/bootstrap-cursor.sh
# Ensure the sandboxed agent HOME exists and is writable by uid 65533
# (the agent children run with a dedicated uid when supported). Best-effort:
# in Kubernetes the emptyDir is fsGroup-chowned; in local docker the image's
# ownership applies only if the directory was not replaced by a volume.
if [[ -n "${CURSOR_AGENT_HOME:-}" ]]; then
mkdir -p "${CURSOR_AGENT_HOME}" 2>/dev/null || true
chmod 777 "${CURSOR_AGENT_HOME}" 2>/dev/null || true
fi
# Session workdirs and MCP sockets live in /tmp (readOnlyRootFilesystem
# deployments mount an emptyDir there). Same best-effort widening for the
# agent child processes.
chmod 1777 /tmp 2>/dev/null || true
# The HTTP server. Sessions spawn cursor-agent ACP subprocesses per request.
exec node /app/src/server.mjs