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

Prevents arbitrary code execution during python/object/new constructor #386

Merged
merged 3 commits into from Mar 17, 2020

Commits on Mar 13, 2020

  1. Prevents arbitrary code execution during python/object/new constructor

    In FullLoader python/object/new constructor, implemented by
    construct_python_object_apply, has support for setting the state of a
    deserialized instance through the set_python_instance_state method.
    After setting the state, some operations are performed on the instance
    to complete its initialization, however it is possible for an attacker
    to set the instance' state in such a way that arbitrary code is executed
    by the FullLoader.
    
    This patch tries to block such attacks in FullLoader by preventing
    set_python_instance_state from setting arbitrary properties. It
    implements a blacklist that includes `extend` method (called by
    construct_python_object_apply) and all special methods (e.g. __set__,
    __setitem__, etc.).
    
    Users who need special attributes being set in the state of a
    deserialized object can still do it through the UnsafeLoader, which
    however should not be used on untrusted input. Additionally, they can
    subclass FullLoader and redefine `get_state_keys_blacklist()` to
    extend/replace the list of blacklisted keys, passing the subclassed
    loader to yaml.load.
    ret2libc committed Mar 13, 2020
    Copy the full SHA
    6f675f7 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    a946ac6 View commit details
    Browse the repository at this point in the history

Commits on Mar 17, 2020

  1. Copy the full SHA
    9091565 View commit details
    Browse the repository at this point in the history