fix(security): prevent prototype pollution via unsanitized config path [MEDIUM] - #1985
fix(security): prevent prototype pollution via unsanitized config path [MEDIUM]#1985ericksoa wants to merge 4 commits into
Conversation
…h [MEDIUM] setConfigValue() tokenized dot-separated config paths from snapshot manifests and traversed into objects without checking for dangerous property names. A crafted snapshot with configPath "__proto__.isAdmin" could pollute Object.prototype, corrupting process-wide state. Add UNSAFE_PROPERTY_NAMES denylist check that rejects __proto__, constructor, and prototype before any traversal occurs. Add regression tests covering all three dangerous keys in both top-level and nested positions, plus legitimate path formats. Reported-by: FailSafe Security Researcher Co-Authored-By: Joshua Medvinsky <joshua-medvinsky@users.noreply.github.com>
Replace `as any` cast with typed narrowing and add braces to void arrow returns to satisfy no-explicit-any and no-confusing-void-expression. Signed-off-by: Test User <test@example.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdded comprehensive prototype pollution defenses to the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Not needed — reopened the original #1558. |
Security Finding: Prototype Pollution via Unsanitized Config Path
Severity: MEDIUM
Reported by: FailSafe Security Researcher
Component:
nemoclaw/src/commands/migration-state.ts—setConfigValue()Description
The
setConfigValue()function tokenizes a dot-separated configuration path and iteratively traverses or builds an object structure to set a value. The function did not sanitize path tokens against dangerous JavaScript property names such as__proto__,constructor, orprototype, allowing an attacker to polluteObject.prototypethrough a crafted snapshot manifest.Fix
Add a denylist check (
__proto__,constructor,prototype) before using each token as a property key. Throws an error if any token matches a dangerous key.Tests
__proto__,constructor,prototype) in both top-level and nested positions are rejectedSupersedes #1558. Closes #1553.
Co-authored-by: failsafesecurity failsafesecurity@users.noreply.github.com
Co-authored-by: Joshua Medvinsky joshua-medvinsky@users.noreply.github.com
Co-authored-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
Release Notes