Skip to content
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

ssh-audit fails when scanning multiple hosts against a policy. #273

Open
hamarituc opened this issue Jun 17, 2024 · 0 comments
Open

ssh-audit fails when scanning multiple hosts against a policy. #273

hamarituc opened this issue Jun 17, 2024 · 0 comments

Comments

@hamarituc
Copy link

How to reproduce

Run ssh-audit version 3.2.0 with the -P and the -T parameter.

Observed behavior

$ ssh-audit -jj -P policy.txt -T ips.txt 
[Traceback (most recent call last):
  File "/XXX/virtualenv/keycheck/bin/ssh-audit", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/XXX/virtualenv/keycheck/lib/python3.11/site-packages/ssh_audit/ssh_audit.py", line 1603, in main
    worker_ret, worker_output = future.result()
                                ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/XXX/virtualenv/keycheck/lib/python3.11/site-packages/ssh_audit/ssh_audit.py", line 1442, in target_worker_thread
    my_aconf = copy.deepcopy(shared_aconf)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/copy.py", line 161, in deepcopy
    rv = reductor(4)
         ^^^^^^^^^^^
TypeError: cannot pickle '_io.TextIOWrapper' object

Additional context

A deep copy of a configuration object is created in ssh_audit.py:1442. This object itself refers to a Policy object which has a property _warning_target set to either sys.stderr (JSON mode) or sys.stdout (normal mode). This object cannot be deep-copied as it contains a non-serializable state (e.g. file position pointer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant