class-pollution.github.io - Python Class Pollution

Example domain paragraphs

Python class pollution is a vulnerability class where untrusted input allows attackers to modify unintended Python runtime objects. It arises from two core Python language features: (i) a uniform object model , where every value is an object and objects expose references to their classes, metadata, and related runtime state through built-in attributes such as __class__ , __base__ , __dict__ , and __globals__ ; and (ii) flexible reflection mechanisms , such as dynamic getattr and setattr , which allow progra

The combination of these two language features becomes dangerous when a program performs a sequence of reflective attribute or item lookups using attacker-controlled names. These lookups may cause the program to traverse from an ordinary object to unintended runtime objects through those built-in attributes, and then modify their content that later affect program behavior. These modifications violate runtime integrity and can lead to severe consequences, including remote code execution (RCE), authentication

Consider a common recursive update function intended to set nested fields of an object based on user input:

Links to class-pollution.github.io (1)