mirror of
https://github.com/hanzoai/agent.git
synced 2026-10-30 15:05:34 +00:00
P0-1: internal/server/middleware/auth.go + grpc_auth.go — APIKeyAuth no longer runs in series after RequireIdentity. The API key is the trust boundary when apiAuth.enabled=true: identity headers become informational, the key's bound org_id (loaded at validation) is authoritative. Rejects 403 on X-Org-Id mismatch with key-bound org. No more X-API-Key + attacker-chosen X-Org-Id = cross-tenant access. P0-2: APIKeyAuth uses crypto/subtle.ConstantTimeCompare. Closes timing leak on bearer-token compare. P0-3: migrations/020_backfill_org_id.sql + 021_org_id_not_null.sql sequence + scripts/audit-org-id.sh + MIGRATION_ORDER.md document the deploy order: 019 add column → audit → 020 backfill from created_by/users.org_id → verify zero empty rows → 021 NOT NULL + CHECK constraint → flip AGENTD_REQUIRE_IDENTITY=true. Hard prereq before any production migration. CC: deployments/helm/hanzo-agents/templates/networkpolicy.yaml allows ingress only from podSelector matchLabels app=hanzoai-gateway. Empty X-Org-Id rejected at middleware in cloud mode (defense-in-depth). Tests: pkg/auth + internal/server/middleware both PASS. Closes Red 2026-04-27 agent findings.
38 lines
1.4 KiB
YAML
38 lines
1.4 KiB
YAML
{{- if .Values.controlPlane.networkPolicy.enabled }}
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: {{ include "hanzo-agents.controlPlane.fullname" . }}
|
|
labels:
|
|
{{- include "hanzo-agents.labels" . | nindent 4 }}
|
|
spec:
|
|
podSelector:
|
|
matchLabels:
|
|
{{- include "hanzo-agents.selectorLabels" . | nindent 6 }}
|
|
app.kubernetes.io/component: control-plane
|
|
policyTypes:
|
|
- Ingress
|
|
ingress:
|
|
# Default-deny: only allow ingress from hanzoai/gateway. The
|
|
# gateway is the trust boundary — it validates the IAM JWT and
|
|
# injects X-Org-Id, X-User-Id, X-User-Email after stripping any
|
|
# client-supplied headers. Direct pod-to-pod traffic from any
|
|
# other workload is refused, closing the
|
|
# "valid-API-key-from-misconfigured-pod + attacker X-Org-Id"
|
|
# cross-tenant attack surface.
|
|
- from:
|
|
- podSelector:
|
|
matchLabels:
|
|
app: hanzoai-gateway
|
|
ports:
|
|
- protocol: TCP
|
|
port: {{ .Values.controlPlane.service.port }}
|
|
- protocol: TCP
|
|
port: {{ include "hanzo-agents.controlPlane.grpcPort" . }}
|
|
# Operator extras: e.g. observability scrapers, internal
|
|
# admin tooling. Keep narrow — only label-selected workloads.
|
|
{{- with .Values.controlPlane.networkPolicy.additionalIngress }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
{{- end }}
|