Overview
Client-side JavaScript security controls can never be fully trusted. Any code sent to the browser can be:- Analyzed using developer tools
- Manipulated by modifying variables and functions
- Bypassed by directly calling backend APIs
- Reverse engineered even when obfuscated
Objective
Submit the phrase “success” to win each level. Each level implements different client-side protections that must be analyzed and bypassed.Server-Side Validation Logic
All levels validate the submission server-side (/vulnerabilities/javascript/index.php:34-72):
- Takes phrase from input field
- Applies ROT13 cipher:
success→fhpprff - Calculates MD5 hash of ROT13’d phrase
- Sets hidden token field
- Regenerate token:
- Open Developer Tools (F12) → Sources tab
- Open
medium.js - Click
{}(Pretty Print button) to de-minify - Read the code to understand logic
- In Console:
High Security
Implementation: Heavily obfuscated JavaScript Source Code: Referenced from/vulnerabilities/javascript/source/high.js (obfuscated)
The code has been obfuscated using multiple packers:
- Dan’s Tools JavaScript Obfuscator
- JavaScript Obfuscator Tool
- Use online deobfuscator: http://deobfuscatejavascript.com/
- Browser interception: Replace obfuscated JS with deobfuscated version
- Dynamic analysis: Use debugger to step through execution
- View page source, find
<script src=".../high.js"></script> - Download
high.js - Paste into http://deobfuscatejavascript.com/
- Read deobfuscated code
- Identify three functions that need to be called
- Use Burp Suite or browser DevTools
- Intercept response for
high.js - Replace with deobfuscated version
- Forward to browser
- Analyze readable code
- Call necessary functions in console
Impossible Security
Implementation: No client-side validation possible Source Code (/vulnerabilities/javascript/source/impossible.php:1):
The file is empty - no JavaScript is loaded.
Message Displayed (/vulnerabilities/javascript/index.php:75-84):
2. Server-Side Validation Always
4. Use JavaScript for UX, Not Security
6. API Authentication
Client-Side Security Anti-Patterns
1. Price/Amount in Hidden Fields
user.role = 'admin' in console.
3. License Validation in JavaScript
Deobfuscation Tools & Techniques
Online Tools
- http://deobfuscatejavascript.com/
- https://beautifier.io/
- https://www.dcode.fr/javascript-unobfuscator
Browser DevTools
- Pretty Print: Click
{}in Sources tab - Debugger: Set breakpoints, step through code
- Console: Call functions, inspect variables
Manual Analysis
Key Takeaways
- JavaScript runs in hostile environment: User has full control
- Never make security decisions client-side: Always validate server-side
- Obfuscation ≠ Security: Can always be deobfuscated
- Use JS for UX: Form validation, animations, interactivity
- Server is source of truth: All important logic server-side
- Assume client is compromised: Design accordingly
- No secrets in client code: API keys, passwords, logic
