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:
+37
-8
@@ -24,11 +24,33 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
||||
apt-get install -y --no-install-recommends nodejs && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# cursor-agent CLI (subscription-backed).
|
||||
RUN curl -fsS https://cursor.com/install | bash && \
|
||||
CURSOR_VERSION_DIR="$(echo /root/.local/share/cursor-agent/versions/*)" && \
|
||||
cp -r "${CURSOR_VERSION_DIR}" /opt/cursor-agent && \
|
||||
ln -sf /opt/cursor-agent/cursor-agent /usr/local/bin/cursor-agent && \
|
||||
# Build stage for the agent layer. The cursor-agent CLI is pinned at build
|
||||
# time from the local cache (populated by `agent update` on the build host;
|
||||
# CI downloads it once per runner via the same cache path). Keeps
|
||||
# permission/sandbox enforcement current without runtime downloads.
|
||||
FROM ubuntu:noble AS agent-stage
|
||||
ARG CURSOR_AGENT_VERSION=2026.10.22-27dcf5f
|
||||
COPY agent-cache/${CURSOR_AGENT_VERSION} /opt/cursor-agent
|
||||
|
||||
FROM ubuntu:noble
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
bash \
|
||||
ca-certificates \
|
||||
curl \
|
||||
tzdata \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Node 20 (LTS) — proxy and stdio MCP bridge both run on Node.
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
||||
apt-get install -y --no-install-recommends nodejs && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# cursor-agent CLI from the pinned build stage.
|
||||
COPY --from=agent-stage /opt/cursor-agent /opt/cursor-agent
|
||||
RUN ln -sf /opt/cursor-agent/cursor-agent /usr/local/bin/cursor-agent && \
|
||||
ln -sf /opt/cursor-agent/cursor-agent /usr/local/bin/agent.real
|
||||
|
||||
# Application code.
|
||||
@@ -37,15 +59,22 @@ COPY scripts/ /app/scripts/
|
||||
COPY cursor-bootstrap/ /opt/cursor-bootstrap/
|
||||
COPY entrypoint.sh /app/entrypoint.sh
|
||||
|
||||
RUN mkdir -p /workspace /home/nobody/.cursor && \
|
||||
# Dedicated HOME for the sandboxed agent child processes. The proxy runs
|
||||
# non-root (uid 65534/nobody) and cannot setuid children, so the child
|
||||
# inherits the pod uid; the separation here is about STATE isolation (the
|
||||
# child's runtime files never touch the PVC-backed proxy HOME).
|
||||
RUN mkdir -p /workspace /home/agent-home /home/nobody/.cursor && \
|
||||
chmod +x /app/scripts/*.sh /app/entrypoint.sh && \
|
||||
chown -R nobody:nogroup /opt/cursor-agent /opt/cursor-bootstrap /app /workspace /home/nobody
|
||||
chown -R 65534:65534 /home/agent-home && \
|
||||
chown -R 65534:65534 /opt/cursor-agent /opt/cursor-bootstrap /app /workspace /home/nobody
|
||||
|
||||
WORKDIR /workspace
|
||||
ENV PORT=4646
|
||||
ENV EDGE_PORT=4647
|
||||
ENV HOME=/home/nobody
|
||||
ENV CURSOR_AGENT_HOME=/home/agent-home
|
||||
ENV NODE_ENV=production
|
||||
USER nobody
|
||||
|
||||
EXPOSE 4646
|
||||
EXPOSE 4646 4647
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
Reference in New Issue
Block a user