BETA Shoulder is in beta — Findings may sometimes be wrong. Your feedback shapes what we fix next. Share feedback

Class/Attribute Pollution

Description

Detects unsafe modification of class attributes or object __dict__ using user input.

How to fix

Whitelist allowed attributes before using setattr.

```python
ALLOWED_ATTRS = {"username", "email"}
if key in ALLOWED_ATTRS:
    setattr(user, key, value)
```

Learn more: https://shoulder.dev/learn/python/cwe-915/class-pollution

Applies to

Languages

References

Scan for this issue

Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=python-class-pollution .

Related rules