Commit fe8d32e
fix: block prototype pollution in baseUnset via constructor/prototype traversal
Block `constructor` and `prototype` unconditionally as non-terminal
traversal keys in baseUnset, matching the approach already used by
baseSet. The previous guard only blocked the specific two-key sequence
`constructor` → `prototype`, allowing attackers to:
- Delete static methods from built-in constructors (Object.keys,
Array.isArray, String.fromCharCode) via paths like
`['constructor', 'keys']`
- Delete built-in prototype methods (toFixed, toLowerCase, valueOf)
via primitive roots like `_.unset(0, 'constructor.prototype.toFixed')`
- Bypass checks entirely using array-wrapped path segments like
`[['constructor'], ['keys']]` which evaded the string-only key check
The primitive root exception that previously allowed constructor.prototype
traversal from primitives (e.g., `_.unset(0, 'constructor.prototype.a')`)
is removed as it enabled deletion of properties on shared built-in
prototypes. Path segments are now normalized with toKey() before
validation.1 parent 18ba0a3 commit fe8d32e
5 files changed
Lines changed: 175 additions & 104 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4375 | 4375 | | |
4376 | 4376 | | |
4377 | 4377 | | |
4378 | | - | |
| 4378 | + | |
| 4379 | + | |
| 4380 | + | |
| 4381 | + | |
4379 | 4382 | | |
4380 | 4383 | | |
4381 | 4384 | | |
4382 | 4385 | | |
4383 | 4386 | | |
4384 | 4387 | | |
4385 | 4388 | | |
4386 | | - | |
4387 | | - | |
4388 | 4389 | | |
4389 | | - | |
4390 | | - | |
4391 | | - | |
4392 | | - | |
4393 | | - | |
4394 | | - | |
| 4390 | + | |
4395 | 4391 | | |
4396 | 4392 | | |
4397 | 4393 | | |
4398 | 4394 | | |
4399 | 4395 | | |
4400 | 4396 | | |
4401 | | - | |
4402 | | - | |
4403 | | - | |
4404 | | - | |
4405 | | - | |
4406 | | - | |
4407 | | - | |
4408 | | - | |
4409 | | - | |
4410 | | - | |
4411 | | - | |
| 4397 | + | |
| 4398 | + | |
| 4399 | + | |
4412 | 4400 | | |
4413 | 4401 | | |
4414 | 4402 | | |
| |||
0 commit comments