Skip to content

Add egress control through allowlist to prevent source code exfiltration - #230

Draft
AbhishekBhaskar wants to merge 2 commits into
mainfrom
abhishekbhaskar/add-egress-allowlist-log-only
Draft

Add egress control through allowlist to prevent source code exfiltration#230
AbhishekBhaskar wants to merge 2 commits into
mainfrom
abhishekbhaskar/add-egress-allowlist-log-only

Conversation

@AbhishekBhaskar

Copy link
Copy Markdown
Contributor

What are you trying to accomplish?

Add domain-based egress control to the proxy to help prevent source-code exfiltration during Dependabot update jobs. Even when an attacker abuses a legitimately-configured registry token (e.g. Artifactory/Nexus), traffic to unknown hosts like evil.com should be visible and, eventually, blockable — something the earlier Method-header approach could not address.

This PR lands the observe (log-only) foundation: it builds a per-job allowlist and logs any request to a host not on it, without changing traffic behavior by default.

Anything you want to highlight for special attention from reviewers?

  • Two independent flags on a new egress_allowlist config block: observe (log non-allowlisted requests, still allow) and enforce (drop with 403, matching the existing blockMetadataAPIHosts response). Both default falsefail-open, so existing jobs and GHES are unaffected.
  • Allowlist source is intentionally minimal for this cut: static GitHub/Dependabot infrastructure domains + static per-ecosystem registry/CDN defaults keyed by PACKAGE_MANAGER. Credential-derived, OIDC-derived, and backend-supplied domains are deliberately deferred.
  • Boundary-safe matching: new helpers.HostMatchesDomain uses a leading-dot suffix check so one entry covers subdomains (npmjs.orgregistry.npmjs.org) while lookalikes like evilnpmjs.org are rejected.
  • Handler placement: registered in proxy.go right after request logging and before all credential-injecting handlers, so drops/logs happen before any auth is added. Works for HTTP and MITM'd HTTPS.
  • enforce is wired but off by default; the intended rollout is observe first, then flip enforce per-ecosystem.

How will you know you've accomplished your goal?

  • Unit: HostMatchesDomain boundary matrix (subdomains, case/trailing-dot normalization, lookalike negatives); handler flag matrix (fail-open, observe-logs-allows, enforce-403, observe+enforce), GitHub-infra always allowed, per-ecosystem defaults applied and cross-ecosystem defaults rejected.
  • Integration (proxy_test.go): end-to-end through MITM — non-allowlisted host returns 403 under enforce and 200 + * egress not allowlisted <host> log under observe.
  • Full suite green: go build ./... and go test ./... pass across all packages.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@AbhishekBhaskar AbhishekBhaskar self-assigned this Sep 2, 2026
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