Conversation
Co-authored-by: joe10832 <103850533+joe10832@users.noreply.github.com>
Co-authored-by: joe10832 <103850533+joe10832@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update Home Directory Check in Shell Script
Fix home directory check in shell scripts to handle tilde (~) input
Sep 24, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a security vulnerability in wallet extension preparation scripts by adding proper validation for the tilde (~) character in directory path checks. The scripts now correctly reject both literal ~ input and expanded home directory paths to prevent dangerous operations.
- Added
"$TARGET_DIR" == "~"check to security validation logic - Applied fix consistently across all three wallet preparation scripts
- Enhanced directory validation to handle both tilde literal and expanded home directory cases
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/cli/prepare-phantom.sh | Added tilde check to directory validation condition |
| src/cli/prepare-metamask.sh | Added tilde check to directory validation condition |
| src/cli/prepare-coinbase.sh | Added tilde check to directory validation condition |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Problem
The shell scripts for wallet extension preparation (
prepare-phantom.sh,prepare-metamask.sh,prepare-coinbase.sh) had a security vulnerability in their directory validation logic. While they correctly checked for the expanded home directory path using"$TARGET_DIR" == "$HOME", they failed to handle cases where users pass the literal tilde character"~"as an argument.The shell expands
~to the full home directory path before the comparison in most contexts, but when passed as a literal string argument to these scripts, the comparison"$TARGET_DIR" == "~"was missing, allowing potentially dangerous operations in the user's home directory.Solution
Added the missing
"$TARGET_DIR" == "~"check to the security validation in all three wallet preparation scripts. The updated condition now properly handles both cases:Before:
After:
Testing
Validated that all scripts now correctly:
"~"input with appropriate error messages$HOMEdirectory as expected/tmp/safe-dirFiles Changed
src/cli/prepare-phantom.sh- Added tilde check on line 40src/cli/prepare-metamask.sh- Added tilde check on line 40src/cli/prepare-coinbase.sh- Added tilde check on line 40.gitignore- Added exclusion fore2e/extensions/directoryThis fix ensures consistent security validation across all wallet preparation scripts and prevents potential misuse when users pass tilde characters as directory arguments.
Created from VS Code via the GitHub Pull Request extension.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.