Skip to content

feat(rules): add PP001 prototype pollution and INJECT001 code injection detection - #3

Merged
lahin31 merged 4 commits into
JSExplore:mainfrom
lahin31:main
Aug 2, 2026
Merged

feat(rules): add PP001 prototype pollution and INJECT001 code injection detection#3
lahin31 merged 4 commits into
JSExplore:mainfrom
lahin31:main

Conversation

@lahin31

@lahin31 lahin31 commented Aug 2, 2026

Copy link
Copy Markdown
Member

What

Two new critical/high severity rules for the Input Validation category.

PP001 — Prototype Pollution via Object Merge (High)

Detects user-controlled input passed to object merge operations without sanitization:

  • Object.assign(target, req.body) — most common vector
  • _.merge / lodash.merge / merge / deepMerge / extend(target, req.body)
  • obj[req.body.key] = value — computed property assignment with user-controlled key

INJECT001 — Code Injection via eval / new Function (Critical)

Detects user-controlled input passed to dynamic code execution sinks:

  • eval(req.body.code)
  • new Function(req.body.code) / new Function('x', req.body.expr)
  • vm.runInNewContext(req.body.script)
  • vm.runInThisContext(req.query.code)
  • new vm.Script(req.body.src)

Both rules use the same containsUserInput() pattern as SQL001 — only fire when
user input (req.body, req.query, req.params, req.headers) appears directly
in the dangerous expression. No false positives for hardcoded strings.

Tests

  • 18 tests for PP001 (Object.assign, lodash merge, computed assignment — true positives and negatives)
  • 14 tests for INJECT001 (eval, new Function, vm module — true positives and negatives)
  • 182/182 passing

Docs updated

  • docs/rules/README.md — PP001 and INJECT001 added to Input Validation table
  • docs/standards.md — OWASP/CWE references for both rules
  • docs/false-positives.md — false positive and false negative documentation for both rules
  • README.md — Input Validation section, rule table, test count
  • CLAUDE.md — rule ID registry, test count

lahin31 and others added 4 commits August 2, 2026 09:53
Remove unnecessary blank lines and separator markers from CLAUDE.md and SECURITY.md for cleaner, more consistent formatting.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Introduce PP001: detects prototype-pollution patterns (Object.assign, lodash/merge-like calls, and computed property assignments) when merging or using user-controlled input (req.body/query/params/headers). Adds src/rules/validation/prototype-pollution.ts, exports the rule from validation/index.ts, updates docs/rules/README.md, and adds unit tests in tests/rules/validation.test.ts. Reports high-severity findings with remediation guidance and references.
Introduce documentation for a new PP001 (Prototype Pollution via Object Merge) rule: adds false-positive guidance (docs/false-positives.md) and standards mapping (docs/standards.md), and updates CLAUDE.md and README.md to include the PP category and bump the test count to 168. Documentation-only changes to reflect the new rule and test suite size.
Introduce INJECT001: a critical Input Validation rule that detects user-controlled input passed to dynamic code sinks (eval, new Function, vm.*). Adds src/rules/validation/code-injection.ts, registers it in src/rules/validation/index.ts, and adds unit tests in tests/rules/validation.test.ts. Update docs and metadata (README.md, CLAUDE.md, docs/false-positives.md, docs/rules/README.md, docs/standards.md) to document the new rule and increase test count. Detects template literals and concatenation of req.body/query/params/headers into execution sinks.
@lahin31
lahin31 merged commit 782f756 into JSExplore:main Aug 2, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant