salt icon indicating copy to clipboard operation
salt copied to clipboard

lgpo.set works w/ Python 2 but not Python 3

Open evenyougreg opened this issue 7 years ago • 2 comments

Description of Issue/Question

I am trying to set an lgpo to satisfy "Hardened UNC Paths" CVE-2015-0008 vulnerability.

I have some minions with Python 2.7.12 and some with Python 3.5.3 and the lgpo that I have to set works on Python 2.7.12 only.

Setup

Hardened UNC Paths:
    lgpo.set:
        - computer_policy:
            'Network\Network Provider\Hardened UNC Paths':
              'Hardened UNC Paths':
                '\\*\NETLOGON': 
                  RequireMutualAuthentication=1, RequireIntegrity=1
                '\\*\SYSVOL': 
                  RequireMutualAuthentication=1, RequireIntegrity=1

Steps to Reproduce Issue

salt m-mnionw state.apply lgpo saltenv=testing

[DEBUG   ] need to compare Network\Network Provider\Hardened UNC Paths from current/requested policy
[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "C:\salt\bin\lib\site-packages\salt\state.py", line 1913, in call
    **cdata['kwargs'])
  File "C:\salt\bin\lib\site-packages\salt\loader.py", line 1898, in wrapper
    return f(*args, **kwargs)
  File "C:\salt\bin\lib\site-packages\salt\states\win_lgpo.py", line 270, in set_
    current_policy_json = salt.utils.json.dumps(current_policy[policy_data['output_section']][pol_id], sort_keys=True).lower()
  File "C:\salt\bin\lib\site-packages\salt\utils\json.py", line 145, in dumps
    return json_module.dumps(obj, **kwargs)  # future lint: blacklisted-function
  File "C:\salt\bin\lib\json\__init__.py", line 237, in dumps
    **kw).encode(obj)
  File "C:\salt\bin\lib\json\encoder.py", line 198, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\salt\bin\lib\json\encoder.py", line 256, in iterencode
    return _iterencode(o, 0)
TypeError: keys must be a string

Results

Functioning minion

Network\Network Provider\Hardened UNC Paths:
    ----------
    Hardened UNC Paths:
        ----------
        \\*\NETLOGON:
            RequireMutualAuthentication=1, RequireIntegrity=1
        \\*\SYSVOL:
            RequireMutualAuthentication=1, RequireIntegrity=1

Non-functioning minion

m-mnionw:
----------
          ID: Hardened UNC Paths
    Function: lgpo.set
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "C:\salt\bin\lib\site-packages\salt\state.py", line 1913, in call
                  **cdata['kwargs'])
                File "C:\salt\bin\lib\site-packages\salt\loader.py", line 1898, in wrapper
                  return f(*args, **kwargs)
                File "C:\salt\bin\lib\site-packages\salt\states\win_lgpo.py", line 270, in set_
                  current_policy_json = salt.utils.json.dumps(current_policy[policy_data['output_section']][pol_id], sort_keys=True).lower()
                File "C:\salt\bin\lib\site-packages\salt\utils\json.py", line 145, in dumps
                  return json_module.dumps(obj, **kwargs)  # future lint: blacklisted-function
                File "C:\salt\bin\lib\json\__init__.py", line 237, in dumps
                  **kw).encode(obj)
                File "C:\salt\bin\lib\json\encoder.py", line 198, in encode
                  chunks = self.iterencode(o, _one_shot=True)
                File "C:\salt\bin\lib\json\encoder.py", line 256, in iterencode
                  return _iterencode(o, 0)
              TypeError: keys must be a string
     Started: 14:19:35.174666
    Duration: 5984.387 ms
     Changes:

Versions Report

Functioning minion:

    Salt Version:
               Salt: 2016.11.5

    Dependency Versions:
               cffi: 1.10.0
           cherrypy: 7.1.0
           dateutil: 2.5.3
          docker-py: Not Installed
              gitdb: 0.6.4
          gitpython: 2.0.8
              ioflo: 1.5.5
             Jinja2: 2.9.4
            libgit2: Not Installed
            libnacl: 1.4.5
           M2Crypto: Not Installed
               Mako: 1.0.4
       msgpack-pure: Not Installed
     msgpack-python: 0.4.8
       mysql-python: Not Installed
          pycparser: 2.17
           pycrypto: 2.6.1
       pycryptodome: Not Installed
             pygit2: Not Installed
             Python: 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)]
       python-gnupg: 0.3.8
             PyYAML: 3.11
              PyZMQ: 16.0.1
               RAET: Not Installed
              smmap: 0.9.0
            timelib: 0.2.4
            Tornado: 4.4.1
                ZMQ: 4.1.6

    System Versions:
               dist:
            machine: AMD64
            release: 2012ServerR2
             system: Windows
            version: 2012ServerR2 6.3.9600  Multiprocessor Free

Non-functioning minion:

    Salt Version:
               Salt: 2018.3.3

    Dependency Versions:
               cffi: 1.10.0
           cherrypy: 10.2.1
           dateutil: 2.6.1
          docker-py: Not Installed
              gitdb: 2.0.5
          gitpython: 2.1.3
              ioflo: Not Installed
             Jinja2: 2.9.6
            libgit2: Not Installed
            libnacl: 1.6.1
           M2Crypto: Not Installed
               Mako: 1.0.6
       msgpack-pure: Not Installed
     msgpack-python: 0.4.8
       mysql-python: Not Installed
          pycparser: 2.17
           pycrypto: 2.6.1
       pycryptodome: Not Installed
             pygit2: Not Installed
             Python: 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)]
       python-gnupg: 0.4.1
             PyYAML: 3.12
              PyZMQ: 16.0.3
               RAET: Not Installed
              smmap: 2.0.5
            timelib: 0.2.4
            Tornado: 4.5.1
                ZMQ: 4.1.6

    System Versions:
               dist:
             locale: cp1252
            machine: AMD64
            release: 2012ServerR2
             system: Windows
            version: 2012ServerR2 6.3.9600 SP0 Multiprocessor Free

evenyougreg avatar Feb 08 '19 20:02 evenyougreg

@Ch3LL Thanks for looking, what now? How should I personally handle this bug?

evenyougreg avatar Feb 18 '19 16:02 evenyougreg

You can sync the module down to your minions or upgrade them to the version containing this fix.

twangboy avatar Mar 19 '19 18:03 twangboy