-
Notifications
You must be signed in to change notification settings - Fork 241
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
[Git HEAD
] py2lcov
and xml2lcov
: Use of subprocess.run([..], shell=True, [..])
allows command injection
#350
Comments
Signed-off-by: Henry Cox <[email protected]>
Handle spaces in path/filename. See #350. Signed-off-by: Henry Cox <[email protected]>
@henry2cox pull request #355 did not solve the underlying problem. I was intentionally not saying that we're dealing with command injection here but maybe I should have said that from the beginning. Short article https://security.openstack.org/guidelines/dg_use-subprocess-securely.html#correct is our case with Python. Would you like me to try a pull request myself and for you to be in the review seat this time? |
HEAD
] py2lcov
and xml2lcov
: Use of subprocess.run([..], shell=True, [..])
breaks support for filenames containing spacesHEAD
] py2lcov
and xml2lcov
: Use of subprocess.run([..], shell=True, [..])
allows shell injection
@henry2cox PS: For proof that the problem persists in similar form (even with #355 merged): # ./bin/py2lcov "with' 'quotes"
/bin/sh: line 1: quotes: command not found
Error: error during XML conversion of with' 'quotes: Command 'COVERAGE_FILE='with' 'quotes' 'coverage' xml -o 'with' 'quotes.xml'' returned non-zero exit status 127. |
HEAD
] py2lcov
and xml2lcov
: Use of subprocess.run([..], shell=True, [..])
allows shell injectionHEAD
] py2lcov
and xml2lcov
: Use of subprocess.run([..], shell=True, [..])
allows command injection
I am of the opinion that a user who deliberately puts quotes and other shell-active characters in paths, is pretty much asking to lose. But sure - if you have a portable fix in mind, feel free. BTW: what timezone are you in? |
@henry2cox thanks! I'll give it a shot.
😄 I'm in UTC+1 and I do sleep but not yet 😄 What's your timezone? |
UTC-5, currently. I think the other aspect is that I'm mostly thinking about (internal) users and various jenkins jobs - which run with the permissions of the user in question, so no particular security issues that didn't already exist. But yeah - I am permitting you to do something nefarious, if you really want to. |
@henry2cox let me first try the pull request and than try answer to that. Starting now… |
@henry2cox ready to review now: #356 |
@henry2cox I guess it would need an environment where (1) the user can influence the filename and (2) cannot normally execute commands on the local box. I'm imagining some web application that uses LCOV in the backend to offer code coverage services to developers. Signalling this as a vulnerability with a CVE would increase the chance to wake up those parties that indeed operate services like that (if any). In case you do support that view, I can take over the https://cveform.mitre.org/ filing to obtain a CVE with question CC @hannob |
The other remaining issue is that the various callbacks are allowed to be either a module or a script. The workaround would be for the service provider to use only module-based callbacks. There may be other issues that I haven't thought of. |
For example:
The two places with this problem are:
lcov/bin/py2lcov
Lines 179 to 182 in 34f05f5
and
lcov/bin/xml2lcovutil.py
Lines 124 to 131 in 34f05f5
Both cases can and should avoid
shell=True
and be good.The text was updated successfully, but these errors were encountered: