Skip to content

UNT162-19: baseline de segurança GKE (PSS restricted, actuator restrito, Gateway só HTTPS) - #21

Merged
devin-ai-integration[bot] merged 2 commits into
masterfrom
devin/unt162-19-gke-security-posture
Nov 5, 2026
Merged

devin-ai-integration[bot] merged 2 commits into
masterfrom
devin/unt162-19-gke-security-posture

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Resumo

Baseline de segurança do s5.4 para o chart deploy/helm/axon-trader (#19), rodado no kind e com revisão estática dos manifests de staging/prod. Ainda não existe cluster GCP de staging, então a re-checagem ao vivo no GKE continua pendente. A lista completa de achados (corrigidos / aceite humano / re-check no GKE) e as CVEs críticas estão em docs/migration/security-baseline.md.

Corrigido neste PR

  • PSS: infra/k8s/platform/namespace.yaml passa de enforce: baseline para enforce: restricted (com enforce-version: v1.33). Os pods do RabbitMQ operator ganham um override restricted (seccomp RuntimeDefault, uid 999, sem privilege escalation, drop: [ALL]). O patch de prod deixa de usar containers: [], que sobrescreveria esse override.
  • kind: ci/kind/setup.sh rotula o namespace com enforce=restricted para todos os checks no kind. Os stand-ins MySQL/RabbitMQ e os pods de probe (kind_probe, que saiu de verify-helm-smoke.sh) agora são compatíveis com restricted.
  • Actuator: no application.properties base, management.endpoints.web.exposure.include=* vira health,info,prometheus (mais data-initializer no trader-app). Assim env, heapdump, configprops etc. somem em qualquer profile (TAS, local, GKE); o profile kubernetes já era restrito.
  • Só HTTPS: Terraform google_compute_ssl_policy (MODERN, TLS 1.2+), output ssl_policy_name e SSL_POLICY_NAME no cluster-env, com um GCPGatewayPolicy no Gateway da plataforma. O Gateway próprio do chart (gateway.create: true) ganha uma rota HTTP→HTTPS 301 (gateway.httpsRedirect). route.hsts adiciona Strict-Transport-Security a todas as respostas roteadas. No kind fica hsts: "", porque o Gateway lá é só HTTP.
  • Novo ci/kind/verify-security-baseline.sh, que cobre PSS, NetworkPolicy, credenciais, actuator e HTTPS.

Para aceite humano

  • F4 (egress): o CNI do kind (kindnet) não aplicou as regras de egress neste host. Os pods do chart alcançaram um alvo sem policy e 1.1.1.1:80, e o script registra isso como INFO. As policies renderizam corretamente, mas o bloqueio de egress precisa ser provado no GKE Dataplane V2.
  • F8: /actuator/info e POST /actuator/data-initializer continuam acessíveis só dentro do cluster, porque os scripts de smoke/e2e dependem deles.
  • F10: as imagens JVM (Boot 2.0.3 / Java 8, mantidas pela decisão d-runtime) têm 48 CVEs críticas distintas, todas já em ci/trivy/critical-baseline.yaml; nenhuma é nova. trader-ui não tem nenhuma critical/high.

Sem mudança de contrato de API: as rotas públicas continuam as mesmas (/, /api/command/*, /api/query/*).

Como testar

# imagens (Java 8)
mvn -B -DskipTests package jib:dockerBuild && docker build -t esarch/trader-ui:latest trader-app-ui
bash ci/kind/verify-security-baseline.sh      # ESARCH_KIND_KEEP=1 mantém o cluster
bash deploy/helm/scripts/validate.sh && bash infra/k8s/scripts/validate.sh
(cd infra/terraform/modules/gke-platform && terraform init -backend=false && terraform test)

Evidências

ESARCH_KIND_KEEP=1 bash ci/kind/verify-security-baseline.sh → SEC_DONE 0, com 63 OK, 0 FAIL e 6 INFO (head atual, sem as linhas repetidas de actuator). Em kind_probe, open exige conexão TCP efetiva: rc 0 é resposta HTTP; rc 1 é a saudação não-HTTP do MySQL/AMQP ("HTTP/0.9 not allowed"), com connect > 0; 52/56 também contam. Já rc 7 (refused) e 6 (DNS) viram error(...), ou seja, FAIL.

{"pod-security.kubernetes.io/enforce":"restricted","pod-security.kubernetes.io/enforce-version":"v1.33","pod-security.kubernetes.io/warn":"restricted"}
OK   namespace enforces restricted
OK   dry-run enforce=restricted: no running pod violates it
OK   root pod rejected: violates PodSecurity "restricted
OK   discovery-server runs as uid 1000
OK   trading-engine runs as uid 1000
OK   trader-app runs as uid 1000
OK   trader-ui runs as uid 101
OK   mysql runs as uid 999
OK   rabbitmq runs as uid 999
OK   app-to-engine: trader-app pod -> <clusterIP>:8080 open(rc=0 connect=0.000273s)
OK   app-to-rabbitmq: trader-app pod -> <clusterIP>:5672 open(rc=1 connect=0.000319s)
OK   engine-to-mysql: trading-engine pod -> <clusterIP>:3306 open(rc=1 connect=0.001686s)
OK   other-to-app: unlabelled pod -> <clusterIP>:8080 blocked
OK   other-to-engine: unlabelled pod -> <clusterIP>:8080 blocked
OK   other-to-mysql: unlabelled pod -> <clusterIP>:3306 blocked
OK   other-to-ui: unlabelled pod -> <clusterIP>:8080 blocked
OK   ui-to-app: trader-ui pod -> <clusterIP>:8080 blocked
OK   ui-to-rabbitmq: trader-ui pod -> <clusterIP>:5672 blocked
OK   eureka-to-engine: discovery-server pod -> <clusterIP>:8080 blocked
OK   app-to-ui: trader-app pod -> <clusterIP>:8080 blocked
OK   other-to-target: unlabelled pod -> 10.244.0.106:8080 open(rc=0 connect=0.000239s)
INFO trader-app pod -> egress-target:8080 open(rc=0 connect=0.000183s) (want blocked; kind CNI egress, re-check on GKE)
INFO trading-engine pod -> egress-target:8080 open(rc=0 connect=0.000147s) (want blocked; kind CNI egress, re-check on GKE)
INFO discovery-server pod -> egress-target:8080 open(rc=0 connect=0.000162s) (want blocked; kind CNI egress, re-check on GKE)
INFO trader-ui pod -> egress-target:8080 open(rc=0 connect=0.000146s) (want blocked; kind CNI egress, re-check on GKE)
INFO trader-app pod -> 1.1.1.1:80 open(rc=0 connect=0.007563s) (want blocked; kind CNI egress, re-check on GKE)
INFO trader-ui pod -> 1.1.1.1:80 open(rc=0 connect=0.006517s) (want blocked; kind CNI egress, re-check on GKE)
OK   no credential in values.yaml (488 lines)
OK   no credential in manifest.yaml (882 lines)
OK   no credential in objects.yaml (881 lines)
OK   credential-like env vars only come from secretKeyRef/envFrom
OK   esarch/discovery-server image env/labels hold no credential
OK   esarch/trading-engine image env/labels hold no credential
OK   esarch/trader-app image env/labels hold no credential
OK   esarch/trader-ui image env/labels hold no credential
OK   Gateway /actuator/env -> 200 (not actuator)
OK   Gateway /actuator/health -> 200 (not actuator)
OK   Gateway /api/actuator/env -> 404 (not actuator)
OK   Gateway /api/actuator/health -> 404 (not actuator)
OK   Gateway /api/actuator/heapdump -> 404 (not actuator)
OK   Gateway /api/command/../actuator/env -> 404 (not actuator)
OK   Gateway /api/query/..%2factuator/env -> 307 (not actuator)
OK   Gateway /api/command/actuator/env -> 404 (not actuator)
OK   trader-app in-cluster /actuator/health -> 200
OK   trader-app in-cluster /actuator/prometheus -> 200
OK   trader-app in-cluster /actuator/env -> 404
OK   trader-app in-cluster /actuator/heapdump -> 404
OK   trading-engine in-cluster /actuator/health -> 200
OK   trading-engine in-cluster /actuator/prometheus -> 200
OK   trading-engine in-cluster /actuator/env -> 404
OK   trading-engine in-cluster /actuator/heapdump -> 404
OK   staging: app HTTPRoute attaches to the https listener only
OK   staging: HSTS set on routed responses
OK   staging: chart-owned Gateway redirects its HTTP listener (301)
OK   prod: app HTTPRoute attaches to the https listener only
OK   prod: HSTS set on routed responses
OK   prod: chart-owned Gateway redirects its HTTP listener (301)
OK   platform Gateway: HTTP listener only 301s to HTTPS
OK   platform Gateway: SSL policy attached (Terraform: MODERN, TLS 1.2+)
PASS: restricted PSS, NetworkPolicy denials, no credentials, actuator internal-only, HTTPS-only Gateway config

Outras verificações:

$ bash deploy/helm/scripts/validate.sh            -> default/staging/prod/kind/kind-gateway: lint OK, kubeconform Invalid: 0 ... OK
$ bash infra/k8s/scripts/validate.sh              -> overlays/staging 22 valid, overlays/prod 16 valid, local/kind 11 valid, Invalid: 0
$ terraform test (modules/gke-platform)           -> Success! 5 passed, 0 failed (nova asserção: ssl policy MODERN / TLS_1_2)
$ mvn -pl trader-app,trading-engine -am test      -> BUILD SUCCESS (Java 8)
$ trivy 0.76.0 image --scanners vuln,secret --severity CRITICAL,HIGH
  trading-engine   CRITICAL=45 HIGH=145  secrets=0  novas críticas fora do baseline=0
  trader-app       CRITICAL=70 HIGH=201  secrets=0  novas críticas fora do baseline=0
  discovery-server CRITICAL=39 HIGH=133  secrets=0  novas críticas fora do baseline=0
  trader-ui        (nenhuma)             secrets=0  novas críticas fora do baseline=0

Os números de CRITICAL contam ocorrências (pacote × CVE); as CVEs distintas estão listadas no doc.

O que não foi testado: o override do RabbitMQ operator só foi validado por render/kubeconform, sem um operator rodando. Também ficam pendentes o egress, o redirect 301, o TLS 1.2 e o HSTS em um GKE real.

Devin-Org: engineering

Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/e3dcab37180349829864f755ef04190b
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/e3dcab37180349829864f755ef04190b?variant=devin
Requested by: @matthewguerra-cog


Devin Review

Status Commit
⚪ Not started —

Run Devin Review

Enable auto-review to review your pull requests automatically.

Devin Review (Staging)


Devin Review

…estrito, Gateway só HTTPS com SSL policy TLS 1.2+, verify-security-baseline.sh no kind

Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

…tou (rc 7 falha); alvo de egress por IP do pod

Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

Resposta à flag do Devin Review "Failed connections pass open-policy checks" (ci/kind/setup.sh:100). A flag não foi postada como thread no GitHub (configuração do repo), por isso respondo aqui.

A flag procede: kind_probe contava curl rc=7 (connection refused) como open. Corrigido em 3f83f7c:

  • blocked: rc 28 com time_connect 0.
  • open(...): só quando o TCP conectou, isto é, rc 0, 1, 52 ou 56, ou rc 28 com time_connect > 0.
  • error(...): rc 7, rc 6 e qualquer outro código. Agora isso reprova um fluxo esperado como open.

Os rc=1 em app-to-rabbitmq / engine-to-mysql vêm da saudação não-HTTP do AMQP/MySQL ("Received HTTP/0.9 when not allowed"), recebida depois do connect. A saída agora mostra o tempo de connect: 0.001064s e 0.000476s.

O critério novo pegou um caso real: other-to-target ... open(rc=7). Logo após o Ready, o kube-proxy ainda não tinha endpoints para o Service do alvo e respondia com REJECT. Agora o probe usa o IP do pod, e o alvo tem uma readinessProbe TCP.

Re-run em 3f83f7c (SEC_DONE 0, 63 OK, 0 FAIL; saída completa na descrição):

OK   app-to-engine: trader-app pod -> <clusterIP>:8080 open(rc=0 connect=0.001022s)
OK   app-to-rabbitmq: trader-app pod -> <clusterIP>:5672 open(rc=1 connect=0.001064s)
OK   engine-to-mysql: trading-engine pod -> <clusterIP>:3306 open(rc=1 connect=0.000476s)
OK   other-to-target: unlabelled pod -> 10.244.0.106:8080 open(rc=0 connect=0.000239s)

Written by Devin

@devin-ai-integration
devin-ai-integration Bot merged commit 5fd3e50 into master Nov 5, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant