Skip to content

security: shell injection in the Telegram notify workflow - #308

Merged
sameerasw merged 1 commit into
sameerasw:mainfrom
Shengcun-Scanner:shengcun/cicd-shell-injection-notify-values
Nov 16, 2026
Merged

sameerasw merged 1 commit into
sameerasw:mainfrom
Shengcun-Scanner:shengcun/cicd-shell-injection-notify-values

Conversation

@Shengcun-Scanner

Copy link
Copy Markdown
Contributor

notify.yml pastes release, issue and pull request fields into the script that
builds the Telegram message:

RAW_BODY="${{ github.event.release.body }}"
TAG="${{ github.event.release.tag_name }}"
...
echo "<a href='${{ github.event.issue.html_url }}'>Issue: ${{ github.event.issue.title }}</a>"
echo "<a href='${{ github.event.pull_request.html_url }}'>PR: ${{ github.event.pull_request.title }}</a>"

Those expressions are expanded before bash parses the script, so the quotes
around them are part of the text bash reads, not a wrapper. A release body, an
issue title or a PR title containing $(…), backticks or a bare " runs
commands on the runner. This workflow triggers on issues: opened and
pull_request: opened, so a stranger can reach it without any maintainer action.

Fix

Move every dynamic field into env: and read variables in the script:

env:
  RELEASE_BODY: ${{ github.event.release.body }}
  RELEASE_TAG: ${{ github.event.release.tag_name }}
  RELEASE_URL: ${{ github.event.release.html_url }}
  ISSUE_TITLE: ${{ github.event.issue.title }}
  ISSUE_URL: ${{ github.event.issue.html_url }}
  PR_TITLE: ${{ github.event.pull_request.title }}
  PR_URL: ${{ github.event.pull_request.html_url }}
run: |
  RAW_BODY="$RELEASE_BODY"
  ...

Variables are expanded after parsing, so the message text stays data. The
existing HTML escaping, sed cleanup and 3000-character truncation are
unchanged, and the Telegram call still receives the same full_message.

Verification

$ R='v1.0$(touch /tmp/pwned)'
$ bash -c 'RAW_BODY="'"$R"'"; :'                  # before
$ ls /tmp/pwned                                    # -> exists
$ RELEASE_BODY="$R" bash -c 'RAW_BODY="$RELEASE_BODY"; :'   # after
$ ls /tmp/pwned                                    # -> not found

Same check for the issue/PR branches (ISSUE_TITLE, PR_TITLE). The file still
parses with yaml.safe_load.

The release body, issue title and pull request title are expanded into the
script that builds the Telegram message, so any of them can run commands on
the runner. Pass them through env instead.

@sameerasw sameerasw left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing it out! <3

@sameerasw
sameerasw merged commit c96af26 into sameerasw:main Nov 16, 2026
1 check passed
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.

2 participants