fix: validate custom install path in install.sh to prevent path traversal#83
Open
xiaolai wants to merge 1 commit intomuratcankoylan:mainfrom
Open
fix: validate custom install path in install.sh to prevent path traversal#83xiaolai wants to merge 1 commit intomuratcankoylan:mainfrom
xiaolai wants to merge 1 commit intomuratcankoylan:mainfrom
Conversation
This was referenced Apr 26, 2026
The custom path entered by the user was passed directly to mkdir -p and cp -r without sanitization. A value containing '..' could write files outside intended directories; a value with shell metacharacters could cause unexpected behaviour. Added rejection of '..' and metacharacters, then canonicalization via realpath before use. Co-Authored-By: Claude Code <noreply@anthropic.com>
c46615a to
325c5c2
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.
Security Fix (Low)
In
examples/digital-brain-skill/scripts/install.sh, when the user selects option 3 (custom location), the input is read viaread -pand passed directly tomkdir -pandcp -rwithout any validation:A user or script that passes a path containing
..segments could write files outside the intended directory. A path containing shell metacharacters could cause unexpected shell behavior depending on how the variable is expanded downstream.Fix
Added validation after the
read -pcall that:..(traversal sequences)/,_,.,-,~, and spacesrealpath --canonicalize-missingto resolve any remaining traversal via symlinks or relative segmentsThe built-in installation paths (options 1 and 2) are not affected since they are constructed from
$HOMEand.respectively, which are trusted values.