fix(deploy): validate package.json name before shell interpolation - #18
Open
ygd58 wants to merge 1 commit into
Open
fix(deploy): validate package.json name before shell interpolation#18ygd58 wants to merge 1 commit into
ygd58 wants to merge 1 commit into
Conversation
Fixes ProjectOpenSea#14. The Vercel project name derived from package.json's "name" field was interpolated directly into a shell command string passed to execSync, allowing arbitrary shell metacharacters in package.json to execute during `tool-sdk deploy`. Adds isValidVercelProjectName() and omits the --project flag (with a warning) when the derived name doesn't match Vercel's allowed project-name charset, instead of shell-interpolating it unchecked. Two regression tests added: a malicious name that must never reach execSync, and a normal scoped name that must still work.
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.
Fixes #14.
Root cause
deploy.tsderives the Vercel project name frompackage.json'snamefield and interpolates it directly into a shell command string passed toexecSync(which runs viash -c). Any shell metacharacter innameexecutes duringtool-sdk deploy.Fix
Adds
isValidVercelProjectName(), validated against Vercel's actual allowed project-name charset ([a-z0-9][a-z0-9._-]*, <=100 chars). If the derived name fails validation, the--projectflag is omitted (matching existing behavior when no name is present) and a warning is logged, instead of shell-interpolating the raw value.Testing
package.jsonname containing shell metacharacters must never reachexecSync.@scope/my-tool) still produces--project=my-toolas before.tsc --noEmitandbiome checkclean on changed files.