Repository navigation
Description
Description
I believe the snapper module's _is_text_file has been broken as part of the security vulnerabilities that were fixed in this pull request: #59648
Steps to Reproduce the behavior
Attempt to run the snapper module's diff function. Or you can run the following code to test (copied from snapper module):
import subprocess
def _is_text_file(filename):
"""
Checks if a file is a text file
"""
type_of_file = subprocess.run(
["file", "-bi", filename],
check=False,
stdout=subprocess.STDOUT,
universal_newlines=True,
).stdout
return type_of_file.startswith("text")
_is_text_file('textfile.txt')If you test this out just in a python file you notice it errors with the following:
OSError: [Errno 9] Bad file descriptor
Expected behavior
For _is_text_file to function correctly
Additional context
** Fix **
This is fixed by changing STDOUT to PIPE. Example:
def _is_text_file(filename):
"""
Checks if a file is a text file
"""
type_of_file = subprocess.run(
["file", "-bi", filename],
check=False,
stdout=subprocess.PIPE,
universal_newlines=True,
).stdout
return type_of_file.startswith("text")I would be happy to submit a pull request for this if this fix is acceptable.
Note that I attempted to notify you of this via the security email address but was ignored. I have detailed the security vulnerability that was fixed by the previous pull request here:
https://sec.stealthcopter.com/saltstack-snapper-minion-privledge-escaltion/
Activity
welcome commentedon Apr 17, 2021
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!
sagetherage commentedon Apr 19, 2021
@stealthcopter
I will look into this, we did receive other emails, but it is true I didn't see one around this issue described. I will get back to you on any findings.
stealthcopter commentedon Apr 19, 2021
@sagetherage Ah sorry, I thought I had included it in the original report but couldn't check due to encrypting it 🤦
sagetherage commentedon Apr 20, 2021
@stealthcopter we did migrate the email address recently, but have received emails before and after the migration date. Can you give me some more details on the email address and date sent? You can send those to me here: [email protected]
thank you!
Fix CVE-2021-31607 in snapper module
Fix CVE-2021-31607 in snapper module
Fix bug introduced in saltstack#59648