a2ui-project / a2ui-project/a2ui
[BUG]: Unsanitized DataModel Path Propagation Enables Prototype Pollution
- Linguagem predominante
- TypeScript
- Estrelas
- 16.4k
- Forks
- 1.3k
- Merge médio
- 2d 13h
- PRs com merge (30d)
- 134
Descrição
# Location
agent_sdks/python/a2ui_core/src/a2ui/core/processing/message_processor.py:192
# Description
The _process_update_data_model function extracts the path parameter from untrusted agent JSON payloads and passes it directly to surface.data_model.set(path, value) without sanitization. Because the underlying Python DataModel lacks filtering for dangerous JSON-Pointer segments (such as __proto__, constructor, or prototype), forwarding these unvalidated paths allows an attacker or compromised agent to inject prototype pollution payloads into the Python server's data model state. When this polluted state is serialized and synchronized back to the JavaScript-based web_core client, it triggers prototype pollution in the host application's browser environment.
# Impact
Prototype pollution on downstream JavaScript clients, potentially leading to Cross-Site Scripting (XSS) or application logic bypass when the maliciously structured data model is synchronized to the web_core renderer.
# Mitigation
Sanitize the path parameter in _process_update_data_model (or within DataModel.set()) by rejecting any JSON-Pointer segments that exactly match __proto__, constructor, or prototype.
# Evidence
```
path = payload.get(\"path\", \"/\")
value = payload.get(\"value\")
# Set dynamically in reactive DataStore without path sanitization
surface.data_model.set(path, value)
```
# Reasoning
The _process_update_data_model function in agent_sdks/python/a2ui_core/src/a2ui/core/processing/message_processor.py takes a path parameter from an untrusted payload and passes it directly to surface.data_model.set(path, value). The set method in agent_sdks/python/a2ui_core/src/a2ui/core/state/data_model.py uses _parse_pointer to split the path, and then iterates over the tokens to auto-vivify intermediate dictionaries and lists before setting the value. Notably, the path tokens are not checked against dangerous keywords like __proto__, constructor, or prototype. While Python dictionaries do not natively support JavaScript-style Prototype Pollution via __proto__ in the same way, the A2UI Threat Model explicitly notes: "CWE-1321 Prototype Pollution - DataModel.set() JSON-Pointer walk lacks proto/constructor/prototype filtering in-tree; a VERIFIED_SECURE patch exists in workspace/patch/ but is pending merge." and states that Kotlin SDK and Swift core are parallel implementations and findings in Python likely port. Since Python data models mirror JS client ones, and potentially sync back, and the TM calls this out explicitly as historically relevant/regression watch, and Python lacks validation that could allow these paths to enter the model and pollute connected JS clients when the model syncs (or cause issues in Python if used via getattr somewhere not immediately visible, though unlikely). The threat model explicitly notes CWE-1321 Prototype Pollution in DataModel.set() JSON-Pointer walk lacking __proto__/constructor/prototype filtering as "historically relevant" and "in-tree". This finding is therefore valid based on the provided code and threat model.
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.