Planning
Overview
With code review complete and functions shortlisted, we now set up the web application locally for testing.
Setting Up Local Environment
Scenario
Provided: Source code + instructions
Backend: Debian-based Linux
No VM/Docker provided
Note: If using Windows, run on Linux VM or PwnBox to match production.
Installation
# Navigate to project
cd ./intro_to_whitebox_pentesting
# Install dependencies
npm installRunning the Application
Output:
Verify Application Works
Response:
β Application running correctly!
Checking for Public Vulnerabilities
npm audit
Output:
If Vulnerabilities Found
Patch (x.x.X)
Safe to update
Minor (x.X.0)
Usually safe
Major (X.0.0)
May have breaking changes
Note: Major updates may require code changes - recommend developers implement.
Testing validateString
Test /api/service/generate Endpoint
Response:
β QR code generated successfully!
Tip: To preview QR code, save to HTML file and open in browser.
Debugging with VSCode
Run in Debug Mode
Open Run and Debug tab in VSCode
Click Run icon next to "Launch Program"
Bottom bar turns red = debug mode active
Add Breakpoint
Open
controllers/service-controllers.jsClick on line number (or
Shift+F9)Red dot appears = breakpoint enabled
Breakpoint on validateString (Line 4)
Re-send Request
Application breaks at breakpoint!
Inspect Variables
In VARIABLES pane:
input: "this is a test"onError: "throw new Error('Invalid input for role: user')"
Breakpoint on Line 20 (generateQR)
Add Breakpoint
Line 20 in service-controllers.js (after try {):
Inspect Variables
text
"this is a test"
role
"user"
req.user
{ email: "test@test.com", role: "user", ... }
Answer: The value of role is user
Debug Workflow Summary
VSCode Debug Controls
βΆοΈ Continue
Resume execution
βοΈ Step Over
Execute next line
β¬ Step Into
Enter function call
β« Step Out
Exit current function
π Restart
Restart debugging
βΉοΈ Stop
Stop debugging
Key Findings So Far
role comes from JWT
Need to control JWT to inject
role = "user" for test@test.com
Role determined by email
onError contains role
Injection via role β eval
No public CVEs
Must exploit custom code
Next Steps
Understand eval injection - How to exploit
eval()Control the role - How is role determined?
Craft payload - Bypass filters, achieve execution
Test exploitation - Confirm vulnerability
Last updated