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:
@@ -30,6 +30,7 @@ spec:
|
||||
labels:
|
||||
app: cursor-agent-api
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
imagePullSecrets:
|
||||
- name: dcr-registry-auth-ro
|
||||
initContainers:
|
||||
@@ -71,6 +72,8 @@ spec:
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 4646
|
||||
- name: http-edge
|
||||
containerPort: 4647
|
||||
env:
|
||||
- name: CURSOR_API_KEY
|
||||
valueFrom:
|
||||
@@ -90,9 +93,15 @@ spec:
|
||||
secretKeyRef:
|
||||
name: cursor-proxy-internal-token
|
||||
key: PROXY_INTERNAL_TOKEN
|
||||
- name: EDGE_PORT
|
||||
value: "4647"
|
||||
volumeMounts:
|
||||
- name: cursor-state
|
||||
mountPath: /home/nobody/.cursor
|
||||
- name: agent-home
|
||||
mountPath: /home/agent-home
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
@@ -114,7 +123,7 @@ spec:
|
||||
memory: 2Gi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
@@ -122,6 +131,15 @@ spec:
|
||||
- name: cursor-state
|
||||
persistentVolumeClaim:
|
||||
claimName: cursor-agent-state
|
||||
# Writable HOME for the sandboxed agent children (uid 65533).
|
||||
- name: agent-home
|
||||
emptyDir:
|
||||
sizeLimit: 512Mi
|
||||
# Writable /tmp for the proxy itself (session workdirs + MCP sockets);
|
||||
# the root filesystem is read-only.
|
||||
- name: tmp
|
||||
emptyDir:
|
||||
sizeLimit: 1Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
@@ -138,8 +156,66 @@ spec:
|
||||
port: 4646
|
||||
targetPort: http
|
||||
---
|
||||
# Edge service: consumed by the Authentik outpost on node2 via the mesh.
|
||||
# NOT exported through MCS — the outpost reaches it over the federation
|
||||
# network using the node4 Service address.
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: cursor-agent-api-edge
|
||||
namespace: cursor-agent-api
|
||||
annotations:
|
||||
service.kubernetes.io/topology-mode: Auto
|
||||
spec:
|
||||
selector:
|
||||
app: cursor-agent-api
|
||||
ports:
|
||||
- name: http-edge
|
||||
port: 4647
|
||||
targetPort: http-edge
|
||||
---
|
||||
apiVersion: multicluster.x-k8s.io/v1alpha1
|
||||
kind: ServiceExport
|
||||
metadata:
|
||||
name: cursor-agent-api
|
||||
namespace: cursor-agent-api
|
||||
---
|
||||
# Edge service exported for the Authentik outpost (node2) via MCS.
|
||||
apiVersion: multicluster.x-k8s.io/v1alpha1
|
||||
kind: ServiceExport
|
||||
metadata:
|
||||
name: cursor-agent-api-edge
|
||||
namespace: cursor-agent-api
|
||||
---
|
||||
# Ingress isolation:
|
||||
# - port 4646 (internal, token-gated): any source (cluster + federation
|
||||
# mesh). Auth is enforced by PROXY_INTERNAL_TOKEN in the app layer —
|
||||
# the Authentik trust header is NOT accepted on this port.
|
||||
# - port 4647 (edge): Authentik outpost only. The outpost runs on node2
|
||||
# (pod CIDR 10.42.0.0/24, preserved across the kilo mesh). Direct
|
||||
# in-cluster access to the edge port is blocked, so the
|
||||
# X-Authentik-Username trust header cannot be forged locally.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: cursor-agent-api-ingress
|
||||
namespace: cursor-agent-api
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: cursor-agent-api
|
||||
policyTypes:
|
||||
- Ingress
|
||||
ingress:
|
||||
- from:
|
||||
- ipBlock:
|
||||
cidr: 0.0.0.0/0
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 4646
|
||||
- from:
|
||||
- ipBlock:
|
||||
cidr: 10.42.0.0/24
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 4647
|
||||
|
||||
Reference in New Issue
Block a user