#19507: security: block prototype pollution in template path resolver
gateway
size: S
## Summary
- Block `__proto__`, `constructor`, and `prototype` segments in template expression path resolution (`getByPath`)
- Prevent prototype pollution attacks via hook transform templates
- Add `BLOCKED_PATH_SEGMENTS` set for efficient lookup
## Security Impact
Prevents prototype pollution which could lead to arbitrary property injection on `Object.prototype`, potentially enabling RCE or data exfiltration through crafted webhook payloads.
## Test plan
- [x] Unit tests for `__proto__` path blocking
- [x] Unit tests for `constructor` path blocking
- [x] Unit tests for nested `prototype` path blocking
- [x] Verify legitimate deep paths still resolve correctly
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds critical prototype pollution protection to template path resolution by blocking `__proto__`, `constructor`, and `prototype` segments in `getByPath`. The security check correctly happens after array indexing but before object property access, preventing attacks via crafted webhook payloads while preserving legitimate deep path access like `messages[0].subject`.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The security fix is correctly implemented with proper placement of the check after array indexing, comprehensive test coverage for all blocked segments and nested cases, and verification that legitimate paths still work
- No files require special attention
<sub>Last reviewed commit: c218084</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#8078: fix(config): add prototype pollution protection to deepMerge
by yubrew · 2026-02-03
81.4%
#23008: Fix prototype pollution in mergeConfigSection and add deepMerge cov...
by Clawborn · 2026-02-21
80.3%
#23473: Hooks/Plugins: enforce discovery root containment
by bmendonca3 · 2026-02-22
71.2%
#8846: fix(tools): block LLM writes to hooks directories
by yubrew · 2026-02-04
70.4%
#21733: security(exec): platform-aware allowlist matching and restricted sa...
by Esubaalew · 2026-02-20
70.2%
#6405: feat(security): Add HTTP API security hooks for plugin scanning
by masterfung · 2026-02-01
69.8%
#22873: fix(tools): enforce global inline-secret blocking for tool inputs
by Kansodata · 2026-02-21
69.7%
#5649: fix(security): harden file permissions and header merging
by sfo2001 · 2026-01-31
69.3%
#8228: fix(link-understanding): block private IPs and internal hostnames i...
by yubrew · 2026-02-03
69.3%
#8818: fix(browser): block unsafe code patterns in browser evaluate
by yubrew · 2026-02-04
69.3%