Open
Conversation
Introduces test vulnerabilities to validate per-PR SAST engine: 1. SQL injection in coupon lookup (routes/coupon.ts:45) - New function lookupCouponByCode() with template literal injection - Source: req.query.code → Sink: sequelize.query() 2. NoSQL injection in order search (routes/orderSearch.ts:16-18) - New file with MongoDB $where operator injection - Source: req.query.email → Sink: ordersCollection.find() 3. SQL injection regression in product search (routes/search.ts:24) - Removed length validation (was substring(0,200), now unlimited) - Makes existing vulnerability worse - tests sanitization tracking 4. SQL injection in basket lookup (routes/basket.ts:47-48) - New function findBasketByOwner() with string concatenation - Source: req.params.owner → Sink: sequelize.query() Expected SAST results: 4 NEW + 6-9 UNCHANGED baseline vulnerabilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…zed query
Security Fix:
- Replaced unsafe MongoDB $where operator with parameterized field matching
- Previous: db.ordersCollection.find({ $where: `this.orderId === '${id}'` })
- Fixed: db.ordersCollection.find({ orderId: id })
This eliminates arbitrary JavaScript execution vulnerability (CWE-943).
Baseline vulnerability at routes/trackOrder.ts:18 is now remediated.
Expected SAST classification: FIXED
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Added route registration for searchOrders() function: - Route: GET /rest/orders/search - Vulnerable to NoSQL injection via $where operator - Source: req.query.email → Sink: ordersCollection.find() This makes the vulnerability exploitable with complete data flow. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Test PR: Per-PR SAST Engine Validation
This PR introduces 2 new injection vulnerabilities, 1 security fix, and 2 precision test cases to benchmark the per-PR SAST analysis engine.
Changes Made
🔴 NEW Vulnerabilities (2)
routes/orderSearch.ts- NoSQL Injection (new file + route registered)$whereoperator with string interpolationGET /rest/orders/searchreq.query.email→ Sink:ordersCollection.find()routes/search.ts- SQL Injection REGRESSIONsubstring(0,200), now unlimited)⚫ PRECISION Test Cases (Must NOT Detect - 2)
routes/coupon.ts- SQL Injection Pattern in Dead CodelookupCouponByCode()contains vulnerable patternroutes/basket.ts- SQL Injection Pattern in Dead CodefindBasketByOwner()contains vulnerable pattern🟢 FIXED Vulnerability (1)
routes/trackOrder.ts- NoSQL Injection REMEDIATED$whereoperator with parameterized query{ $where: \this.orderId === '${id}'` }`{ orderId: id }Expected SAST Results
What This Tests
✅ Classification: NEW vs UNCHANGED vs FIXED
✅ Precision: True data flow analysis (not just pattern matching) - 12 pts of grading
✅ Performance: ~5-10 min speedup from skipped agents
✅ Regression Detection: Sanitization degradation tracking