Skip to content

mitogen.utils.cast() can silently fail to cast string subtypes (e.g. AnsibleUnsafeText) #1046

Closed

Description

@moreati

mitogen.utils.cast(v) is intended to recursively replace subtypes of builtins in v. In versions of Ansible that have addressed CVE-2023-5764 it silently fails to do so for ansible.utils.unsafe_proxy.AnsibleUnsafeText() et al. The cause is that cast() calls str() on the value, and in these versions of Ansible AnsibleUnsafeText() overrides __str__() to return itself.

This was one of the root causes of #221, but this was obscured by the lack of an immediate warning or error.

Further discussion/investigation in https://github.com/mitogen-hq/mitogen/wiki/AnsibleUnsafe-notes

Fix/mitigations in progress.

>>> import ansible, ansible.utils.unsafe_proxy, mitogen.utils
>>> ansible.__version__
'2.14.14'
>>> unsafe_text = ansible.utils.unsafe_proxy.wrap_var('abc')
>>> type(unsafe_text)
<class 'ansible.utils.unsafe_proxy.AnsibleUnsafeText'>
>>> type(mitogen.utils.cast(unsafe_text))
<class 'ansible.utils.unsafe_proxy.AnsibleUnsafeText'>

Activity

  1. added
    bugCode feature that hinders desired execution outcome
    affects-0.3Issues related to 0.3.X Mitogen releases
    on Mar 26, 2024
  2. self-assigned this
    on Mar 26, 2024
  3. added 4 commits that reference this issue on Mar 28, 2024
    fd69c82
    be1708e
    7694334
    2252bc0
  4. added 2 commits that reference this issue on Jul 10, 2024
    3e0700f
    2656958
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

affects-0.3Issues related to 0.3.X Mitogen releasesbugCode feature that hinders desired execution outcome

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions