feat(rules): add PP001 prototype pollution and INJECT001 code injection detection - #3
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 keyINJECT001 — 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 whenuser input (
req.body,req.query,req.params,req.headers) appears directlyin the dangerous expression. No false positives for hardcoded strings.
Tests
Docs updated
docs/rules/README.md— PP001 and INJECT001 added to Input Validation tabledocs/standards.md— OWASP/CWE references for both rulesdocs/false-positives.md— false positive and false negative documentation for both rulesREADME.md— Input Validation section, rule table, test countCLAUDE.md— rule ID registry, test count