in

Prototype pollution-like bug variant found in Python

317f twittercard python pp

[ad_1]

“Class pollution” flaws similar to the dangerous vulnerability types found in JavaScript and similar languages

Prototype pollution-like variant found in Python

Prototype pollution is a dangerous class of bugs associated with the most popular prototype-based language in JavaScript.

However, one researcher found a variant of prototype pollution applicable to Python, although other class-based programming languages ​​may be vulnerable to similar attacks.

From Prototype Pollution to Class Pollution

In JavaScript, each object inherits the “prototype” of its parent object, which contains all the attributes and functionality of that object. A JavaScript object can traverse its parent’s prototype to access its functionality.

Prototypes can change at runtime, making JavaScript dynamic and flexible, but also dangerous. Prototype poisoning attacks exploit this property to change the behavior of JavaScript applications to perform malicious actions.

Class-based languages ​​such as Python are probably immune to such manipulation.

Love this kind of content? tell us about your experience Daily Swig get swag

However, security researcher Abdulraheem Khaled has discovered a coding scheme that allows attackers to perform prototypal poisoning-like attacks against Python programs. In a blog post documenting his findings, he called it “class pollution.”

Khaled said Daily Swig He says he discovered the attack while trying to translate the concept of JavaScript prototype pollution to Python.

Working with Python classes

To poison a Python object, an attacker needs an entry point that uses user input to set the object’s attributes. If user input determines both attribute names and values, attackers can exploit it to manipulate program behavior.

“An important factor to look at is whether the application uses unsanitized user-controllable input to set attributes on objects (controls which attribute name to set and its value),” Khaled said. Told. Daily Swig.

If the target function uses a recursive loop to traverse the object’s attributes, the attacker may be able to access parent classes, global variables, etc. Khaled calls this an “unsafe merge”.

For example, attackers can use such capabilities to modify command strings executed by the system, change the values ​​of critical variables, or cause denial-of-service attacks by causing critical classes to malfunction. (DoS) can be triggered.

Unlike JavaScript, Python class pollution attacks are limited by the operations possible on built-in object types.

Background Prototype Pollution: A Dangerous and Underrated Vulnerability Affecting JavaScript Applications

“Unlike JS [JavaScript], global/embedded object classes are immutable, so attributes cannot be set. This imposes some restrictions when looking for gadgets,” he says Khaled.

Modification of base object prototypes is one of the primary attack vectors in JavaScript prototype pollution. This limits Python attacks to some extent.

However, Khaled notes that a weak merge function could allow an attacker to overcome this limitation by allowing access to global in-app variables and other classes defined in Python programs or imported modules. I discovered that there is

class pollution in the wild

According to Khaled, any kind of Python application can be vulnerable to this kind of attack as long as it receives unsanitized user input and implements some form of unsafe object attribute assignment. .

During his research, he found several instances of popular Python libraries with dangerous merge functions that exposed them to class pollution attacks.

The minimal impact of class poisoning is DoS. However, attacks can have a deeper impact on Python web applications such as:

  • Overwrite private key Used to sign sessions and manually create valid sessions in Flask web applications for account takeover attacks
  • Avoid filters – Bypass the path traversal prevention implemented in Jinja, for example when trying to load a template file. This allows the attacker to load files from any local directory without being restricted to the template directory, allowing disclosure and inclusion of local files.
  • Remote command executionby overriding the COMSPEC or PATH environment variables

“Prototype pollution is definitely one of the topics that deserves more attention from the community, and has gotten more attention lately,” Khaled said.

“Class pollution may be a new vulnerability that has only recently been uncovered. [but] I expect to see it in other programming languages ​​soon. ”

you might like it too Developers urged to rotate secrets after CircleCI breach

[ad_2]

Source link

What do you think?

Leave a Reply

GIPHY App Key not set. Please check settings

    1673221508filter php

    Quick Tip: How to Filter Data in PHP

    og image

    Moving Analytics Launches Single Sign-On to Enhance Data Security and Improve User Experience