How can a PR comment expose AWS credentials in a GitHub Actions workflow?

November 24, 2026 5 answers
Asked by Tavmira!8c

I saw an incident where a comment on a public repository led to AWS credentials appearing in a workflow log. How can a comment execute anything, and what would prevent the same thing from happening?

Answers

_3n!plavex.8

The workflow can be vulnerable without anyone merging a malicious pull request. An issue_comment event can run a workflow from the default branch when someone comments on a pull request. If that workflow inserts the comment body directly into a run script, the shell can interpret parts of the comment as code.

Treat the comment as untrusted data. Pass it through an environment variable or another data channel rather than interpolating it into the script, quote shell expansions, and validate the commands and arguments you actually intend to accept. Passing it through an environment variable alone is not enough if you later feed it to eval or another shell interpreter.

Tavmira!8c:

So the workflow itself was already vulnerable, and the comment supplied the input. No change to the repository code was needed?

3m!RivetPanda:

Right. The dangerous boundary was where comment text became shell syntax in a workflow that was already allowed to run.

Reply to this answer
Vexlori+7w

OIDC removes the need to store long-lived AWS keys, but it does not make a workflow safe to run untrusted input. A compromised job with permission to request an OIDC token can use it to assume any AWS role whose trust policy accepts that token.

Check the role trust policy's audience and subject conditions. Avoid broad subject wildcards that let unrelated branches, environments, or pull request contexts assume a production role. Where appropriate, use a protected GitHub environment and restrict who can deploy to it. Also grant the role only the AWS permissions the job needs, especially avoiding unnecessary IAM write access.

NimbleCrouton-3:

Limit id-token: write to the jobs that need it too. That does not fix injection, but it reduces which jobs can request an OIDC token.

Reply to this answer
7u~cobblepouch_394

Don't count on log masking as your security boundary. In the reported incident, credentials were encoded before being printed, so masking missed them. Keep untrusted input out of privileged jobs and avoid printing tokens or credential material at all.

If credentials may have leaked, treat them as compromised. Contain the role and sessions, review CloudTrail for their use, and investigate what the role could have changed. Alerting can help catch activity, but it is not a substitute for restricting the trust and permissions in the first place.

Reply to this answer
qV.42!

One design option is to stop having CI push deployments directly into AWS. A deployment system in the target environment can pull approved artifacts instead, so the application workflow may not need AWS credentials at all.

That won't fit every project. A service that responds to public comments and calls AWS still needs some way to access AWS, so its command handling and role permissions need their own careful boundaries.

Reply to this answer
6b+gobletpouch_419

The launch attempts in that incident were blocked by an organization policy requiring IMDSv2, but that was a lucky constraint, not a credential theft control. Requests using different instance metadata settings could have had a different result.

Defense in depth is useful, just don't mistake an unrelated denial for proof that the exposed role or workflow is safe.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions