Skip to content

feat(control): pipelineMustNotSendSecretsToUntrustedHosts (ISSUE-311) - #530

Open
thomasboni wants to merge 4 commits into
mainfrom
feat/secret-egress-control
Open

thomasboni wants to merge 4 commits into
mainfrom
feat/secret-egress-control

Conversation

@thomasboni

@thomasboni thomasboni commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Why

In the GhostAction campaign (GitGuardian, September 2025, and its 2026 return), attackers pushed a workflow named "Github Actions Security" to hundreds of repositories. Its single curl step POSTed ${{ secrets.* }} values, with names harvested from the repository's legitimate workflows, to http://193.32.204.199. Over three thousand secrets left that way. Run against a reproduction of that workflow, Plumber today raises only ISSUE-801 (missing permissions). Nothing names the exfiltration line.

This PR adds pipelineMustNotSendSecretsToUntrustedHosts (ISSUE-311, critical) on GitHub and GitLab so that shape is caught before it runs.

What fires

One shell command of a script line fires when it has all three parts:

  • a network client: curl, wget, nc/ncat/netcat, Invoke-WebRequest/Invoke-RestMethod/iwr/irm, httpie http/https, with or without .exe, bare, by path (/usr/bin/curl), escaped (\curl) or quoted at command start; and git, only when the secret sits in the remote URL's userinfo or in an http.extraheader config value;
  • a secret: on GitHub ${{ secrets.NAME }}, or $NAME/${NAME}/$env:NAME/%NAME%/${{ env.NAME }} where NAME is bound to secrets.* at workflow, job or step level; on GitLab a masked project CI/CD variable, or CI_JOB_TOKEN and the other predefined tokens;
  • a literal destination outside the trusted set: http(s)://host[:port], a bracketed IPv6 literal, a bare IPv4, or a schemeless host (the client's first positional argument past flags, the value of --url/-Uri, or a dotted host carrying a path or port). A host that is only a side argument (a proxy -x, a --resolve map, a header value, -o out.txt) is not a destination. A secret in the URL userinfo counts, and the destination is the host after the last @.

Lines are read one command at a time: &&, ||, ; and & cut the association, a pipe carries a secret forward, a $(...) or backtick substitution is its own command. Lines starting with # and trailing unquoted comments are ignored; trailing-backslash continuations are joined first. One finding per job and destination, naming the secrets.

Configuration

pipelineMustNotSendSecretsToUntrustedHosts:
  enabled: true          # on by default, both providers
  trustVcsHosts: true    # GitHub: github.com, api.github.com, uploads.github.com, ghcr.io, *.githubusercontent.com,
                         #         plus the instance host and *.<host> on GitHub Enterprise Server
                         # GitLab: the instance host and registry.<host>
  trustedHosts: []       # host[:port] globs, e.g. "*.internal.example.com", "10.*", "2606:4700:*"

A numeric glob such as 10.* matches IP literals only, never a hostname like 10.attacker.example. A glob without a port does not cover the same host with a port: add host:*. IPv6 entries may be written with or without brackets.

What stays silent, and why

  • A destination held in a variable ("$WEBHOOK_URL"): not judged, never a fake verdict.
  • An unmasked variable on GitLab: not a secret by the project's own declaration.
  • A secret with no network client, or a client with no secret, in the same command.
  • Calls to the VCS itself: $CI_API_V4_URL, the literal instance host, api.github.com, the GHES instance.
  • Loopback (localhost, 127.0.0.0/8, ::1) and a single-label service alias (http://docker:2375, postgres): the secret stays on the runner. Built in, not configurable.
  • A fetch and a secret-bearing command on one line (curl https://get.example/x | sh && npm publish --token $SECRET): different commands.
  • A secret given to the outer tool while a $(curl ...) fetches config: different commands.
  • A proxy, --resolve, or header value naming a host the client does not connect to.
  • On GitLab the masked flags come from the settings-variables lane. Without it the control reports not_evaluable, not a pass.

Evidence

  • Suite, golangci-lint and the deadcode check are clean. 117 fixtures under policies/testdata/ISSUE-311/ (66 GitHub, 51 GitLab) cover each trigger part, each silence and each review finding; goldens, fingerprint pins and the message-style lint cover the new code.
  • GitHub reproduction of the GhostAction workflow: one critical ISSUE-311 for github_actions_security/send-secrets naming VPS_HOST, VPS_SSH_KEY and VPS_USER to 193.32.204.199. ISSUE-801 still fires. A benign ssh deploy workflow in the same repo stays silent.
  • GitLab, standalone and real CI on gitlab.com/thomasboni/test2 branch plumber/e2e-secret-egress (ten cases): both report the same three findings (PASSWORD to 193.32.204.199, CI_JOB_TOKEN and PASSWORD to collector.evil.example) and all seven clean cases (instance API, literal instance host, unmasked variable, no client, variable destination, localhost, service alias) are silent. Pipeline on the final commit (image built from 6d02f6c): https://gitlab.com/thomasboni/test2/-/pipelines/2924756077, job 17018189858. The standalone runs were repeated with the final binary after every review round.
  • Platform mode: the control joins the existing variables lane, so it adds no GitLab request. In-process tests cover the lane served, degraded and absent, and the call inventory is unchanged.
  • Five bot review rounds (16 findings) addressed; every thread answered with its fixture names.

Follow-ups

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vcwjp52YnStKHvPcRmVQrR

Comment thread policies/secret_egress.rego Resolved
Comment thread policies/secret_egress.rego Resolved
Comment thread control/task.go Resolved
Comment thread policies/secret_egress.rego Resolved
Comment thread policies/secret_egress.rego Resolved
@thomasboni
thomasboni force-pushed the feat/secret-egress-control branch from 7bd14e3 to d2a6910 Compare October 8, 2026 00:37
Comment thread control/task.go Resolved
Comment thread policies/secret_egress.rego Resolved
@thomasboni
thomasboni force-pushed the feat/secret-egress-control branch from d2a6910 to 277015b Compare October 8, 2026 00:59
Comment thread policies/secret_egress.rego Resolved
Comment thread policies/secret_egress.rego Resolved
@thomasboni
thomasboni force-pushed the feat/secret-egress-control branch from 277015b to 0bbbff8 Compare October 8, 2026 01:27
Comment thread policies/secret_egress.rego Resolved
Comment thread cmd/init.go Resolved
Comment thread policies/secret_egress.rego Resolved
Comment thread policies/secret_egress.rego Resolved
@thomasboni
thomasboni force-pushed the feat/secret-egress-control branch from 0bbbff8 to 2601f7c Compare October 8, 2026 01:53
Comment thread cmd/render_details.go Resolved
Comment thread cmd/legacy_json.go Resolved
Comment thread policies/secret_egress.rego Resolved
thomasboni and others added 4 commits October 8, 2026 02:19
…311)

A script line that uses a network client to send a secret to a host the
policy does not trust is a critical finding, one per job and host. GitHub
reads the secrets context and env bindings; GitLab reads masked settings
variables and the predefined tokens and abstains without the variables
lane. Unresolvable destinations stay silent by design.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The engine config carries the provider's VCS hosts (GitHub's fixed set,
the GitLab instance and registry hosts from the configured URL). On
GitLab the control joins the settings-variables lane: it is collected
with it, degrades with it and reports not_evaluable without it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…fault

Terminal stats, legacy JSON (secretEgressResult) and the MR comment carry
the new control; the shipped default enables it on both providers with
the VCS hosts trusted; config init offers it as a composition.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…311)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@thomasboni
thomasboni force-pushed the feat/secret-egress-control branch from 2601f7c to 6d02f6c Compare October 8, 2026 02:21
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