Why JavaScript Analysis is Your Competitive Edge
The bug bounty landscape is increasingly competitive. Thousands of hunters target the same programs, and low-hanging fruit gets picked within hours of launch. Client-side JavaScript analysis, particularly of obfuscated code, is one of the most underutilized techniques in bug bounty hunting.
Most hunters focus on server-side testing. But client-side JavaScript often contains the roadmap: hidden endpoints, authentication logic, API keys, business logic flaws, and debug modes are all embedded in the code sent to every user's browser.
The Economics of JavaScript Analysis
- Low: $100-500 for information disclosure, minor XSS
- Medium: $500-2,000 for authenticated IDOR, stored XSS
- High: $2,000-10,000 for broken authentication, privilege escalation
- Critical: $10,000-50,000+ for RCE, mass data exposure, account takeover
JavaScript analysis disproportionately leads to high and critical findings because it reveals internal architecture.
JavaScript Reconnaissance
Comprehensive Script Collection
1// Monitor all script loading in browser console
2const scriptLog = [];
3const origAppend = Node.prototype.appendChild;
4Node.prototype.appendChild = function(element) {
5 if (element.tagName === 'SCRIPT' && element.src) {
6 scriptLog.push({
7 src: element.src,
8 timestamp: Date.now(),
9 caller: new Error().stack.split('\n')[2].trim()
10 });
11 console.log('[Script Loaded]', element.src);
12 }
13 return origAppend.call(this, element);
14};
15console.table(scriptLog);Collection Strategies
- Crawl the entire application: visit every page, click every button
- Check for Webpack chunk manifests or asset manifests
- Monitor network requests filtered by JS MIME type
- Check for source maps: append
.mapto JS URLs - Use the Wayback Machine for older, less protected versions
- Analyze mobile app web views for less obfuscated bundles
Finding Hidden API Endpoints
Why Hidden Endpoints Exist
- Deprecated features removed from UI but not backend
- Admin or debug endpoints left accessible
- Internal tools meant to be network-restricted
- Future features already deployed server-side
- Testing endpoints that lack rate limiting
Extraction After Deobfuscation
1// Hidden endpoints revealed in deobfuscated code
2const apiRoutes = {
3 getUser: '/api/v2/users/{id}',
4 updateUser: '/api/v2/users/{id}',
5 listUsers: '/api/v2/users',
6 // Hidden admin endpoints
7 exportAllUsers: '/api/v2/admin/users/export',
8 impersonateUser: '/api/v2/admin/impersonate/{id}',
9 systemConfig: '/api/v2/admin/config',
10 debugLog: '/api/v2/internal/debug/log',
11 resetUserPassword: '/api/v2/admin/users/{id}/reset-password'
12};
13
14// GraphQL queries found in client code
15const ADMIN_MUTATION = `
16 mutation PromoteUser($userId: ID!) {
17 promoteToAdmin(userId: $userId) {
18 id
19 role
20 }
21 }
22`;Testing Hidden Endpoints
- Access control: Can you reach it without authentication?
- Parameter manipulation: Change user IDs, add admin parameters
- HTTP method testing: Try GET, POST, PUT, DELETE, PATCH
- Rate limiting: Are hidden endpoints rate-limited?
API Key and Secret Exposure
1// Secrets found in deobfuscated code
2const cloudConfig = {
3 accessKeyId: 'AKIAIOSFODNN7EXAMPLE',
4 secretAccessKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
5 region: 'us-east-1'
6};
7
8const paymentKey = 'sk_live_51HxxxxxxxxxxxxxxxxxxxxS';
9
10const firebaseConfig = {
11 apiKey: 'AIzaSyXXXXXXXXXXXXXXXXXXXXXXX',
12 authDomain: 'project.firebaseapp.com',
13 projectId: 'project-id'
14};Impact Assessment
- Critical: Cloud secret keys, payment secret keys, database credentials
- High: Private API keys with broad permissions
- Medium: Restricted API keys with limited scope
- Low: Publishable keys meant to be public
Authentication and Authorization Weaknesses
1// Client-side role check - easily tampered with
2function checkAccess(user, requiredRole) {
3 const roleHierarchy = {
4 'viewer': 1, 'editor': 2,
5 'admin': 3, 'superadmin': 4
6 };
7
8 // Client-side only - no server validation!
9 if (roleHierarchy[user.role] >=
10 roleHierarchy[requiredRole]) {
11 return true;
12 }
13 window.location.href = '/unauthorized';
14 return false;
15}
16
17// JWT token handling revealing algorithm
18function decodeToken(token) {
19 const parts = token.split('.');
20 const header = JSON.parse(atob(parts[0]));
21 // Reveals: {"alg": "HS256", "typ": "JWT"}
22 return JSON.parse(atob(parts[1]));
23}What to Look For
- Client-side role checks without server validation
- Token generation logic revealing algorithm weaknesses
- Session management exposing fixation or hijacking vectors
- Feature flags enabling premium or admin features
Client-Side Validation Weaknesses
1// Deobfuscated pricing logic
2function calculateDiscount(cart, couponCode) {
3 const discounts = {
4 'SAVE10': { type: 'percentage', value: 10 },
5 'SAVE20': { type: 'percentage', value: 20 },
6 'EMPLOYEE50': { type: 'percentage', value: 50 },
7 'BETA_FREE': { type: 'percentage', value: 100 }
8 };
9 if (discounts[couponCode]) {
10 return applyDiscount(cart, discounts[couponCode]);
11 }
12 return cart;
13}Prototype Pollution Discovery
1// Vulnerable deep merge in deobfuscated code
2function deepMerge(target, source) {
3 for (const key in source) {
4 if (typeof source[key] === 'object' && source[key] !== null) {
5 if (!target[key]) target[key] = {};
6 deepMerge(target[key], source[key]);
7 } else {
8 target[key] = source[key];
9 }
10 }
11 return target;
12}
13
14// Used with user-controlled input:
15const userPrefs = JSON.parse(userInput);
16deepMerge(appConfig, userPrefs);
17// Exploit: {"__proto__": {"isAdmin": true}}XSS in Obfuscated Code
Deobfuscation reveals unsafe DOM manipulation patterns hidden in obfuscated rendering logic. Look for functions that insert user-controlled content directly into the DOM using methods like Element.insertAdjacentHTML() or property assignments to element content properties without proper sanitization.
1// Template rendering with no sanitization
2function renderTemplate(template, data) {
3 return template.replace(
4 /\{\{(\w+)\}\}/g,
5 (match, key) => data[key] || ''
6 // No HTML encoding applied!
7 );
8}
9// The rendered output is then inserted into the DOM
10// via unsafe DOM APIsBug Bounty Hunting Workflow
Phase 1: Reconnaissance (30 min)
- Enumerate all JavaScript files
- Identify obfuscated vs. minified files
- Download obfuscated files
- Check for source maps
Phase 2: Deobfuscation (10-30 min)
- Upload to Astify
- Review results
- Re-process if needed
Phase 3: Analysis (1-3 hours)
- Search for API endpoints and URL patterns
- Look for hardcoded credentials and tokens
- Analyze authentication logic
- Identify client-side validation gaps
- Map data flows from input to server
- Note unsafe DOM manipulation patterns
Phase 4: Testing (1-4 hours)
- Test endpoints for access control issues
- Verify exposed credentials
- Test authentication for weaknesses
- Check whether validation is enforced server-side
- Exploit XSS sinks and prototype pollution
Phase 5: Reporting (30-60 min)
- Document with clear reproduction steps
- Include before/after code snippets
- State impact clearly
- Suggest remediation
Tips for Maximizing Payouts
Chain Vulnerabilities
An exposed endpoint (medium) + authentication flaw (high) = critical chain worth significantly more than either alone.
Focus on Business Impact
Frame findings in business terms: "Any unauthenticated user can export all customer records including payment data."
Target JavaScript-Heavy Applications
SPAs built with React, Angular, or Vue contain extensive client-side logic. E-commerce, fintech, and SaaS dashboards are ideal targets.
Responsible Disclosure
- Report through official channels (HackerOne, Bugcrowd)
- Do not access real user data
- Do not cause service disruption
- Respect program scope and rules
- Allow time for remediation
JavaScript deobfuscation gives you the ability to see what other hunters miss. Astify's automated deobfuscation combined with systematic analysis helps you consistently find high-value vulnerabilities.