Code Injection
Overview
The onError String
`throw({message: 'The input "${text}" contains the following invalid characters: [${text.match(
/['"`;]/g
)}]', statusCode: 403})`With text = ";"
text = ";"throw {
message: 'The input ";" contains the following invalid characters: [;]',
statusCode: 403,
};Injection Points
Point
Location
Usability
Building the Payload
Step 1: Escape the String
Step 2: Comment Out Rest
Step 3: Close Parentheses/Braces
Three Rules for Injection
Rule
Description
Handling Syntax Errors
JSON Escaping
Code Injection Attempt
Payload
Expected Result
Send Request
Check Console
Debugging the Failure
Set Breakpoint
Copy Value
As Executed Code
The Problem: throw Statement
The Fix: Same Line Execution
Problem
Solution
New Payload
Result
Working Payload Analysis
Payload
Part
Purpose
As Executed
Updated Checklist
#
Step
Status
Key Lessons Learned
1. Build Payload Gradually
2. Understand JavaScript Execution
3. Debug When Stuck
4. VSCode Hints
5. JSON Escaping
Summary
Issue
Solution
Last updated