Repository navigation
fix: eliminate shell injection in Telegram notify steps - #71
Merged
Merged
Conversation
The Notify Build Start/Complete and Notify Deploy Complete/Failure
steps interpolated ${{ github.event.head_commit.message }} (and
actor/timestamp/repository/secrets) directly into a run: bash script
inside a double-quoted curl argument. A commit message containing
backticks or double quotes breaks or hijacks the script:
- PR #69's message contained `time`, which bash expanded as command
substitution (harmlessly ran the `time` builtin here, but the
primitive is a real injection point).
- PR #70's message contained embedded double quotes, which closed the
-d text="..." string early and caused a bash syntax error (exit 2).
Both caused the job to abort at the very first step, before checkout,
so neither PR's deploy ever ran the build/deploy steps.
Fix: route every untrusted/secret value through env: (context
expressions there are not re-parsed by the shell) and reference them
as $VAR inside the script, using GITHUB_REPOSITORY/GITHUB_ACTOR
(already provided by the runner) for repo/actor. Also switch from -d
to --data-urlencode so control characters in the commit message can't
corrupt the form-encoded POST body sent to Telegram.
Verified against the two commit messages that broke prod deploys plus
a payload with backticks, $(), and embedded quotes/semicolons — no
syntax error and no code execution in any case.
Drive-by: fixed mojibake '�' -> '📦' in the Build Complete message.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
cmnisal
approved these changes
Sep 25, 2026
rayaanr
approved these changes
Sep 25, 2026
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 two most recent prod deploys (#69, #70) failed before
Checkout Codeeven ran — not a build/deploy problem, a shell-injection bug in the Telegram notify steps.Root cause
Notify Build Start/Notify Build Complete/Notify Deploy Complete/Notify Deploy Failureinterpolate${{ github.event.head_commit.message }}(plus actor/timestamp/repository/secrets) directly into arun:bash script, inside a double-quotedcurl -d text="..."argument. Any commit message containing shell metacharacters breaks or hijacks the script:`time`— bash expanded it as command substitution (harmlessly ran thetimebuiltin here, but it's a live injection primitive)."Create wallet error: Not Found") — closed the-d text="..."string early, causing a bash syntax error (exit 2).Both aborted the job at the very first step, so neither PR's build/deploy steps (checkout, SCP, SSH build+restart) ever ran on the server.
Fix
${{ }}interpolation inrun:and intoenv:— context expressions set as an env var are never re-parsed by the shell, so backticks/quotes/$()in a commit message can't be interpreted.GITHUB_REPOSITORY/GITHUB_ACTORinstead of re-interpolatinggithub.repository/github.actor.-dto--data-urlencodeso control characters in the commit message can't corrupt the form-encoded POST body sent to Telegram's API.build-deploy.yml(prod) andbuild-deploy-dev.yml(dev), which share the same pattern.�→📦in the "Code Checked Out" message.Verification
Reproduced both failing commit messages plus an explicit attack payload (backticks,
$(), embedded quotes/semicolons) against the fixed script locally: all parse cleanly, no syntax error, no command execution.Test plan
yaml.safe_loadboth edited workflow files — valid YAMLrun:scripts locally against the two commit messages that broke prod, and an adversarial payload — no syntax error, no injected command executionmain/devsends the Telegram notification correctly and deploys as expected🤖 Generated with Claude Code