fix: prevent command injection in nightly workflow @W-24289114@ - #2938
Merged
Merged
Conversation
Move user-controlled `inputs.only` from direct GitHub expression expansion in `run:` blocks to `env:` blocks, where the value becomes a shell variable instead of inline script text. Add input validation to reject values containing shell metacharacters.
iowillhoit
previously approved these changes
Sep 24, 2026
iowillhoit
reviewed
Sep 24, 2026
| if: ${{ inputs.only != '' }} | ||
| shell: bash | ||
| run: | | ||
| if [[ ! "$INPUT_ONLY" =~ ^[@a-zA-Z0-9/_,.~-]+$ ]]; then |
Contributor
There was a problem hiding this comment.
We could remove the ~ here. No packages passed to --only will have a ~
No packages passed to --only will contain a tilde.
iowillhoit
approved these changes
Sep 24, 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
inputs.onlyfrom direct${{ }}expression expansion inrun:blocks toenv:blocks, so the value is treated as shell variable data — not inline script text that bash re-parses for metacharactersonlyvalues containing characters outside the npm package name charset (defense-in-depth)$ONLY_FLAGis intentionally unquoted (word-splitting required for--only <value>to become two separate CLI arguments)Vulnerability
The
workflow_dispatchinputonly(a free-form string) was interpolated directly intorun:steps via${{ inputs.only }}. GitHub expression expansion happens before the shell parses the generated script, so shell metacharacters in the input (;,|,`,$()) become live syntax. The same job exportsSVC_CLI_BOT_GITHUB_TOKENasGITHUB_TOKEN, creating a command injection → secret exfiltration path for any actor withworkflow_dispatchaccess.Work Item
@W-24289114@: [Frontier Strike][Core] salesforcecli/cli nightly workflow command injection can expose service bot token
Proof of Work
js-yamlparse — clean)${{ inputs.* }}in anyrun:block across all workflows (one other instance inpromote.ymlis a boolean input — safe)Validation
sf-releasehandles gracefully)format()specifier injection — all mitigatedTest plan
onlyvalue (e.g.@salesforce/core) — should succeedonly— should succeed (same as cron path)foo;echo pwned) — should fail at validation step