-
Notifications
You must be signed in to change notification settings - Fork 354
Fix shell injection in rez-build process #1979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix shell injection in rez-build process #1979
Conversation
…ngs in environment variables Signed-off-by: Jean-Christophe Morin <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1979 +/- ##
==========================================
- Coverage 60.01% 58.80% -1.21%
==========================================
Files 163 163
Lines 20098 20100 +2
Branches 3494 3494
==========================================
- Hits 12062 11820 -242
- Misses 7224 7458 +234
- Partials 812 822 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Jean-Christophe Morin <[email protected]>
value = list(map(quote, value)) | ||
value = ' '.join(value) | ||
else: | ||
value = quote(str(value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This protects against cases where a user passes something like
rez-build --myarg '$(run command)'
We were already doing that for elements in sequences anyway.
Signed-off-by: Jean-Christophe Morin <[email protected]>
Signed-off-by: Jean-Christophe Morin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test with the script output might be a little high-maintenance when making other changes to rez (potentially) and could be adjusted to one where you simply assert that the contents you expressed are in the script per-line, rather than the exact script equivalence, but that doesn't mean the fix and the test aren't both valid, so I am marking it approved, leaving it up to you to make the test less finicky if you choose to.
Fixes #417
Fixes #797
Fixes #937
Fixes #964
Fixes #1107
Fix shell injection in rez-build process caused by non-sanitized strings in environment variables.
Note that it doesn't improve the security by a lot. By design building something will execute code other than rez's code. But it increases security by relying on the principle of least surprise (it is very surprising to see random stuff in a string assigned to a variable named "description" to execute any code. Thre is another another side effect to this PR, which is the reduction in attack surface. No SCA (source code analysis) tool would be able to detect the vulnerable packages today without custom rules. With this PR, this problem goes away.
Marking as draft until we can add tests.