Skip to content

[BUG] Snapper module _is_text_file function broken #60046

Closed

Description

@stealthcopter

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

  1. added
    bug
    on Apr 17, 2021
  2. welcome commented on Apr 17, 2021

    @welcome

    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!

  3. added
    Regression
    severity-medium
    and removed on Apr 19, 2021
  4. added this to the Approved milestone on Apr 19, 2021
  5. modified the milestones: Approved, Silicon on Apr 19, 2021
  6. assigned
    and
    dwoz
    and unassigned on Apr 19, 2021
  7. sagetherage commented on Apr 19, 2021

    @sagetherage
    Contributor

    @stealthcopter

    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/

    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.

  8. stealthcopter commented on Apr 19, 2021

    @stealthcopter
    Author

    @sagetherage Ah sorry, I thought I had included it in the original report but couldn't check due to encrypting it 🤦

  9. sagetherage commented on Apr 20, 2021

    @sagetherage
    Contributor

    @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!

  10. added a commit that references this issue on Apr 27, 2021
  11. added a commit that references this issue on May 12, 2021
  12. modified the milestones: Silicon, Approved on Aug 11, 2021
  13. added a commit that references this issue on Aug 30, 2021
    197e7d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

RegressionSilicon v3004.0bugseverity-medium

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions