fix: harden gstack-slug against shell injection via eval#181
Open
Ty-Robb wants to merge 1 commit intogarrytan:mainfrom
Open
fix: harden gstack-slug against shell injection via eval#181Ty-Robb wants to merge 1 commit intogarrytan:mainfrom
Ty-Robb wants to merge 1 commit intogarrytan:mainfrom
Conversation
Whitelist safe characters (a-zA-Z0-9._-) in SLUG and BRANCH output to prevent shell metacharacter injection when used with eval. Only affects self-hosted git servers with lax naming rules — GitHub and GitLab enforce safe characters already. Defense-in-depth.
a1cc067 to
02c76d3
Compare
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
Addresses #133
Hardens
bin/gstack-slugagainst shell injection when used witheval $(gstack-slug). Appends| tr -cd 'a-zA-Z0-9._-'to the SLUG and BRANCH pipelines, whitelisting only safe characters in the output. Shell metacharacters (;,$, backticks,|,&, etc.) are stripped before they reacheval.Changes
bin/gstack-slug— Added character whitelist to both pipelines (+2 lines, inline with existingtrcalls)test/skill-validation.test.ts— Added assertion that output values contain only safe charactersRisk
None. Output is unchanged for standard GitHub/GitLab repos — org names, repo names, and branch names already use only safe characters. Only affects edge cases with self-hosted git servers or crafted branch names.
gstack-diff-scopeuses the sameeval $(...)pattern but is not affected — it only outputstrue/falseliterals.Test plan
SLUG=Ty-Robb-gstack BRANCH=fix-shell-injection-gstack-slugPre-Landing Review
No issues found — change is 2 lines of pipeline hardening + 9 lines of test.