fix(deployment/solutils): validate archive paths to prevent Zip Slip#22405
Open
ozpool wants to merge 1 commit into
Open
fix(deployment/solutils): validate archive paths to prevent Zip Slip#22405ozpool wants to merge 1 commit into
ozpool wants to merge 1 commit into
Conversation
downloadProgramArtifacts extracted tar entries using only filepath.Base, which silently flattens path-traversal entries (e.g. "../../etc/passwd") into the target directory rather than rejecting them. While Base prevents the worst case of writing outside targetDir, it can still cause silent filename collisions when a malicious archive ships crafted entries. Reject any tar entry whose name is not local via filepath.IsLocal (empty, absolute, or containing ".."), and additionally verify with filepath.Rel that the resolved output path is contained within the cleaned targetDir as defense-in-depth. Closes smartcontractkit#21003
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
downloadProgramArtifactsindeployment/utils/solutils/artifacts.gopreviously relied solely onfilepath.Basewhen extracting tar entries.filepath.Basesilently flattens path-traversal entries like../../etc/passwdtopasswdinstead of rejecting them, which can mask malicious archives and cause silent filename collisions.filepath.IsLocalreturns false for empty paths, absolute paths, and any path that traverses outside the target via..).filepath.Relthat the cleaned output path is contained within the cleanedtargetDirbefore writing.TestDownloadProgramArtifacts_RejectsZipSlipEntriescovering parent traversal, nested traversal, absolute paths, and empty entry names. Confirms no file is written inside or outside the target directory when a malicious archive is served.Test plan
go test ./utils/solutils/... -count=1fromdeployment/— all tests pass including the new Zip Slip cases and existing extraction/cancellation/URL/non-existent-dir tests.go vet ./utils/solutils/...— clean.gofmt -l deployment/utils/solutils/— clean.