# GHSA-mw26-5g2v-hqw3: DeepDiff Class Pollution in Delta Class Leading to RCE

## Description

### Summary
A critical class pollution vulnerability exists in DeepDiff's Delta class that allows attackers to modify Python class attributes at runtime, leading to denial of service, remote code execution, and authentication bypass.

### Impact
An attacker who can control input to the Delta class can:
1. Execute arbitrary OS commands (RCE)
2. Corrupt built-in classes causing DoS
3. Modify application secrets for authentication bypass

## Vulnerability Details

- **Advisory**: GHSA-mw26-5g2v-hqw3
- **CVE**: CVE-2025-58367
- **CWE**: CWE-915 (Improperly Controlled Modification of Dynamically-Determined Object Attributes)
- **CVSS Score**: 10.0 (Critical)
- **Package**: deepdiff
- **Ecosystem**: pip
- **Affected Versions**: >= 5.0.0, <= 8.6.0
- **Fixed Version**: 8.6.1

## Technical Details

Python class pollution is a novel vulnerability (CWE-915) where attackers can modify class attributes through object manipulation.

### Attack Vector 1: Path Bypass via Tuple Representation
The Delta class accepts dictionaries with paths as keys. While string paths are filtered, tuple representations bypass security:

```python
Delta({
    "dictionary_item_added": {
        (("root", "GETATTR"), ("__init__", "GETATTR"), 
         ("__globals__", "GETATTR"), ("PWNED", "GET")): 1337
    }
})
```

### Attack Vector 2: Pickle + Gadget Chain
When Delta receives bytes, it deserializes via pickle. The SAFE_TO_IMPORT allowlist can be polluted to include dangerous modules like "posix.system", then exploited in a second call.

## References

- https://github.com/seperman/deepdiff/security/advisories/GHSA-mw26-5g2v-hqw3
- https://nvd.nist.gov/vuln/detail/CVE-2025-58367
