Harden EKS deployment: Zero Trust pod security, NetworkPolicies, and policy-as-code CI gate#240
Open
devin-ai-integration[bot] wants to merge 5 commits into
Open
Conversation
…and policy-as-code CI gate Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Author
Zero Trust hardening summaryThis PR reduces the EKS attack surface with one focused, reviewable change plus a CI gate to keep it from regressing. Controls added (control → threat mitigated):
Verification evidence (local):
Out of scope (follow-ups): mirror controls into the Helm chart, replace deprecated |
Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR applies one focused, reviewable Zero Trust hardening pass to the bankapp Kubernetes deployment (the actual EKS attack surface) and wires a policy-as-code gate into CI so the controls cannot silently regress.
Note on scope: the task referenced Terraform IaC, but this repo contains no Terraform — the IaC is the raw manifests in
kubernetes/plus a Helm chart inhelm/, and CI is a Jenkins pipeline (Jenkinsfile) that calls a privateSharedlibrary (not in-repo, so it can't be run/validated here). The hardening therefore targets the Kubernetes manifests that are actually deployed via the GitOps CD pipeline.Three controls, each with a regression gate:
securityContextonbankappandmysqldeployments.Controls added → threat mitigated
runAsNonRoot: true,runAsUser/Group,fsGroupseccompProfile.type: RuntimeDefaultallowPrivilegeEscalation: false,privileged: falseCAP_SYS_ADMINabuse)readOnlyRootFilesystem: true(+emptyDirfor/tmp, and mysql runtime dirs)capabilities.drop: [ALL]NET_RAWARP/DNS spoofing)default-deny-ingressNetworkPolicyallow-bankapp-from-ingress-nginx(8080)allow-mysql-from-bankapp(3306).github/workflowsKey implementation details
readOnlyRootFilesystemrequires explicit writable mounts. The app only needs/tmp(JVM + embedded Tomcat scratch). MySQL additionally needs writable runtime dirs, mounted asemptyDir:The Conftest policy (
policy/kubernetes-security.rego) enforces the container/pod controls per-document;policy/networkpolicy.regoruns in--combinemode to assert a default-deny ingress NetworkPolicy exists. Both have unit tests (*_test.rego).Verification evidence (run locally)
Trivy IaC config scan (
--severity HIGH,CRITICAL) on the two deployments:Conftest gate correctly fails closed on the un-hardened manifests and passes on the hardened ones:
The same Conftest + Trivy commands run on every PR via the new
IaC Securityworkflow.Not in scope (follow-ups)
helm/chart templates.openjdk:17-alpinebase image and remediating image-layer CVEs (the new Trivy gate makes these visible for a focused follow-up).Link to Devin session: https://app.devin.ai/sessions/4313fb49ecd0461a9ffadd6e9a4caa08
Requested by: @achalc
Devin Review