fix: prevent path traversal in GitHub plugin getter filename#13680
Merged
Conversation
anurag5sh
approved these changes
Jul 21, 2026
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.
What
ExpectedFileNamein the GitHub plugin getter returned the raw filename from the remoteSHA256SUMSrelease asset unchanged. That string was used directly infilepath.Jointo build both the temp execution path and the final install path, allowing a crafted filename containing../sequences to escape the plugin directory.Why it matters
An attacker who controls a GitHub plugin release (malicious plugin, or a compromised legitimate one) could write the plugin binary to an arbitrary path writable by the victim user, and have it executed immediately via
exec.Command(path, "describe")atpacker inittime — before the plugin is ever used in a build.The release getter (
packer/plugin-getter/release/getter.go) was never affected because it already reconstructed the filename from validated fields instead of trusting the remote string.How
Mirror the release getter's approach: reconstruct the expected filename entirely from the fields
Init()already parsed and validated (BinVersion,ProtVersion,Os,Arch,Ext). The raw remotezipFileNameargument is ignored.For a well-formed filename the output is identical to before, so there is no impact on any existing legitimate plugin.
Changes
packer/plugin-getter/github/getter.go— fixExpectedFileNamepacker/plugin-getter/github/getter_test.go— update test to use a populated entry; add explicit traversal-filename assertionpacker/plugin-getter/plugins_test.go— updatemockPluginGetterto mirror the real implementation so integration tests exercise the fixed code pathBackward compatibility
No breaking change. A legitimate plugin filename round-trips through
Init()→ExpectedFileName()to the identical string as before.