fix(deploy): restrict workflow-runner egress to required destinations#1430
Merged
OleksandrUA merged 1 commit intoJun 1, 2026
Merged
Conversation
The workflow-runner-block-imds NetworkPolicy only blocked link-local (169.254/16), leaving runner pods able to reach all of RFC1918, CGNAT and in-VPC services (RDS, Redis, other pods) over egress. A compromised runner (e.g. SSRF via an http-request step that slips past SAFE_FETCH_ENFORCE) could pivot to internal hosts. Replace the single permissive rule with a union of explicit allows and deny-the-rest: - DNS to kube-dns only - keeperhub-sandbox :8787 (delegated code execution) - keeperhub-executor :3080 (metrics ingest) - RDS Postgres :5432, scoped to the dedicated DB subnets - public internet (all ports) with 10/8, 172.16/12, 192.168/16, 169.254/16, 100.64/10 and 127/8 stripped; IPv6 keeps NAT64 while blocking link-local and ULA In-cluster Services are matched by podSelector because the VPC CNI policy agent evaluates egress on the post-DNAT backend pod IP. Public egress is left port-unrestricted so non-443 RPC/webhook endpoints keep working. Validated both manifests with kubectl apply --dry-run=server against the live API servers.
🧹 PR Environment Cleaned UpThe PR environment has been successfully deleted. Deleted Resources:
All resources have been cleaned up and will no longer incur costs. |
ℹ️ No PR Environment to Clean UpNo PR environment was found for this PR. This is expected if:
|
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.
Problem
workflow-runner-block-imdsonly blocked link-local (169.254.0.0/16). Runner pods could still reach all of RFC1918, CGNAT and in-VPC services (RDS, Redis, other pods) over egress. A runner compromised through an SSRF vector that slips past the L7SAFE_FETCH_ENFORCEguard could pivot to internal hosts. This is a SEV-1 postmortem follow-up.Change
Replaced the single permissive egress rule with a union of explicit allows; everything else is denied. The runner needs exactly four destinations, each gets its own rule:
:8787- delegated code-step execution:3080- metrics ingest (EXECUTOR_METRICS_INGEST_URL):5432- scoped to the dedicated DB subnets (the runner writes execution state directly viaDATABASE_URL)10/8,172.16/12,192.168/16,169.254/16,100.64/10,127/8stripped; IPv6 keeps NAT64 reachable while blocking link-local and ULA (IMDSv6 sits infc00::/7)In-cluster Services are matched by
podSelectorrather than CIDR because the VPC CNI Network Policy Agent evaluates egress on the post-DNAT backend pod IP. Public egress is left port-unrestricted on purpose so non-443 RPC / webhook endpoints keep working; destination filtering at L7 stays the job ofSAFE_FETCH_ENFORCE.Both files edited (staging applies on this merge, prod applies on the later
staging->prodPR); only the RDS subnet CIDRs differ between envs.Network facts (verified live, read-only, 2026-06-01)
10.0.0.0/1610.1.0.0/1610.0.100.0/24,.101.0/24,.102.0/2410.1.100.0/24,.101.0/24,.102.0/2410.x(no100.64secondary CIDR)Validation
kubectl apply --dry-run=serveragainst the live API servers (reportsconfigured- in-place update of the existing policy, same name, no orphan).Post-merge verification plan (staging, before promoting to prod)
app=workflow-runnerdebug pod: confirm IMDS169.254.169.254and an arbitrary10.1.xhost are denied, while RDS:5432and public443succeed.Risk: staging applies to all runner Jobs on merge. If a workflow needs an in-cluster endpoint not accounted for here, it would fail at run time (not deploy time) - the verification step above is what catches that before prod.