Repository navigation
Stop PKGMAN_Exec from parsing its arguments - #158
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #158 +/- ##
=======================================
Coverage 92.38% 92.38%
=======================================
Files 26 26
Lines 1313 1313
=======================================
Hits 1213 1213
Misses 100 100
🚀 New features to boost your workflow:
|
|
I'm having a bit of trouble with this. What is the problem that this PR is attempting to solve, and what is the intention of |
PKGMAN_Exec joined its arguments with spaces and handed the result to 'sh -c', so an argument containing a space was split, and one containing '$(...)' or ';' was executed. Such arguments include archive names taken from downloaded package metadata. Pass command and arguments to the shell as positional parameters instead; it still adds the '2>&1', but never parses them. The tar version check passed an empty string meaning "no option", which is now an argument of its own, so it passes nothing instead. Assisted-by: Generative AI
|
Claude replying here:
gap> PKGMAN_Exec(".", "printf", "[%s]", "a b", "$(echo injected)").output;
"[a][b][injected]" # master
"[a b][$(echo injected)]" # this PRThis can happen in practice. For example, a user whose home directory is It is also a potential security issue. The archive name passed to On the new line: Calling I have rebased this onto the new master. |
15d33cf to
c594654
Compare
|
Makes sense, and I added a test that now passes because of this. |
Claude writing here:
PKGMAN_Execjoins its arguments with spaces and runs the result withsh -c, so an argument with a space is split and one with$(...)or;is executed. Archive names are the last component of aPackageInfo.g'sArchiveURL, so a crafted URL runs code attar xf.The shell now gets command and arguments as positional parameters (
sh -c 'exec "$0" "$@" 2>&1' cmd arg...): it still merges stderr, but never parses them. #104 is unaffected.Two callers passed
""to mean "no option" (non-GNUtar,hg status); they now pass nothing.