fix(compilers): reject path-like compiler versions before artifact write - #2922
Closed
0xoasis wants to merge 1 commit into
Closed
fix(compilers): reject path-like compiler versions before artifact write#29220xoasis wants to merge 1 commit into
0xoasis wants to merge 1 commit into
Conversation
OpenAPI CompilerVersion allows trailing junk after semver (.*), so values like 0.8.28/../../../tmp/pwn can make path.join(repo, fileName) escape the compiler cache directory. Downloads usually 404, but the path construction is still unsafe. Validate version/fileName for separators and `..`, resolve under the repo root, and share the helper across solc/vyper/fe getters.
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
OpenAPI
CompilerVersionuses^v?\d+\.\d+\.\d+.*$, so values like0.8.28/../../../tmp/pwnpass validation.path.join(solcRepo, \solc-${platform}-v${version}`)` can then escape the compiler cache directory.Successful arbitrary write still requires a 200 from the compiler CDN (URLs are percent-encoded, so this usually 404s), but path construction is unsafe and should be rejected early.
Fix
resolveCompilerArtifactPathhelper rejects separators /..and ensures the resolved path stays under the repo rootgetSolcExecutableearly throwRelated
Validation
# from packages/compilers npx mocha --exit test/compilerArtifactPath.spec.ts