Advanced Penetration Testing Techniques: IDOR, JWT Attacks, and API Vulnerabilities

With the rapid adoption of web applications and APIs, attackers have shifted their focus towards exploiting flaws in how these systems manage data and authentication. Modern penetration testing goes beyond classic attacks and delves into more sophisticated techniques such as IDOR (Insecure Direct Object References) and JWT (JSON Web Token) manipulation.
This comprehensive guide will take you through the most critical vulnerabilities, advanced attack techniques, and best practices to secure your applications.
1. Insecure Direct Object References (IDOR)
Keyword: IDOR Vulnerability
IDOR (Insecure Direct Object References) is an Access Control Vulnerability that arises when applications directly reference objects (such as database entries) without proper authorization checks. This can lead to unauthorized data access or modification.
1.1 How IDOR Works
IDOR typically occurs when developers rely solely on user-supplied input to access objects without verifying permissions.
Example of an IDOR Flaw:
GET /api/user/profile?id=1234 HTTP/1.1
Host: example.com
In this scenario, changing the ID parameter to another user's ID might expose or modify another user's data.
1.2 Techniques to Exploit IDOR
1.2.1 Parameter Tampering
Modify parameters in URLs, forms, or headers to access restricted data.
GET /api/user/profile?id=4321
1.2.2 API Endpoint Manipulation
APIs are particularly vulnerable as they often expose object IDs in URL paths:
POST /api/orders/4567/cancel
Changing 4567
to another order ID may cancel someone else’s order.
1.2.3 Burp Suite Automation
Automate IDOR discovery with Burp Intruder by brute-forcing the ID parameter.
- Use Payload Processing to detect changes in response length or content.
- Analyze response headers and content to identify discrepancies.
1.3 How to Prevent IDOR
Keyword: Preventing IDOR Attacks
- Access Control Verification: Always verify permissions before granting access.
- Use Indirect References: Instead of exposing IDs, use UUIDs or hashed values.
- Implement Role-Based Access Control (RBAC): Restrict access based on user roles.
- Code Review and Testing: Regularly audit the code to identify insecure references.
2. JSON Web Token (JWT) Attacks
Keyword: JWT Attack Techniques
JSON Web Tokens (JWT) are widely used for authentication and data transmission between clients and servers. However, improper implementation can introduce serious vulnerabilities.
2.1 How JWT Works
A typical JWT consists of three parts:
- Header: Specifies the algorithm and token type.
- Payload: Contains claims like user information.
- Signature: Ensures the integrity of the token.
JWT Structure:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwicm9sZSI6ImFkbWluIn0.YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=
2.2 Common JWT Attacks
2.2.1 None Algorithm Attack
If the server incorrectly supports the "none" algorithm, attackers can remove the signature and bypass authentication.
Example:
Replace the algorithm in the header to none
and remove the signature:
{
"alg": "none",
"typ": "JWT"
}
2.2.2 Signature Forging (HMAC to RSA Attack)
If the server uses RS256 but mistakenly verifies it as HS256, attackers can craft a valid token using the public key as the secret.
2.2.3 Token Bruteforcing
Use tools like JWT Cracker to bruteforce weak signing keys:
jwtcrack -t eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
2.3 How to Secure JWTs
Keyword: Secure JWT Implementation
- Use Strong Signing Algorithms: Prefer RS256 over HS256.
- Validate Token Integrity: Check the signature before decoding.
- Implement Token Expiry: Set short-lived tokens with automatic renewal.
- Rotate Signing Keys: Regularly update keys and invalidate old ones.
3. API Vulnerabilities: Attacks and Countermeasures
Keyword: API Security Testing
APIs are increasingly targeted due to their critical role in modern applications. Understanding common API vulnerabilities is crucial for robust security.
3.1 API Attack Techniques
3.1.1 Mass Assignment
Attackers can exploit improperly handled object mapping to modify fields:
{
"username": "john",
"isAdmin": true
}
3.1.2 Bypassing Rate Limiting
Attackers bypass rate limits by changing headers or using multiple IP addresses.
- Use tools like Turbo Intruder to stress-test rate-limiting mechanisms.
3.1.3 GraphQL Introspection Abuse
By querying GraphQL's introspection endpoint, attackers can enumerate all available fields:
{
__schema {
types {
name}
}
}
3.2 How to Secure APIs
Keyword: API Security Best Practices
- Input Validation: Sanitize and validate all incoming data.
- Implement Rate Limiting: Prevent brute-force and DoS attacks.
- Authentication and Authorization: Enforce strict token policies (OAuth 2.0).
- Disable Unused Endpoints: Remove or restrict access to unused API functions.
- Security Testing: Regularly scan with tools like OWASP ZAP and Burp Suite.
4. Advanced Exploitation Techniques
Keyword: Advanced Exploitation Techniques
In addition to the common vulnerabilities mentioned above, advanced exploitation involves chaining multiple vulnerabilities.
4.1 Attack Chaining: IDOR + JWT Manipulation
- IDOR to Access JWT: Exploit IDOR to retrieve another user’s JWT token.
- JWT Manipulation: Modify the JWT to escalate privileges.
- Privilege Escalation: Access admin functionalities using the forged JWT.
4.2 Exfiltrating Data via API Flaws
Leverage GraphQL and REST APIs to extract sensitive data without triggering alerts:
- Use GraphQL queries to enumerate data fields.
- Automate data extraction with custom scripts.
- Conceal activity with low-frequency requests to avoid detection.
5. Reporting and Documentation
Keyword: Pentesting Report Best Practices
After a successful penetration test, documenting the findings is crucial.
- Vulnerability Descriptions: Clearly explain the issue and its impact.
- Proof of Concept (PoC): Provide evidence of successful exploitation.
- Mitigation Recommendations: Offer concrete steps to fix the issue.
- Severity Ratings: Prioritize based on risk and business impact.
Conclusion
Advanced penetration testing requires a deep understanding of modern web application vulnerabilities and advanced exploitation techniques. By mastering attacks like IDOR exploitation, JWT manipulation, and API vulnerabilities, you can enhance your skills as a penetration tester and deliver more comprehensive security assessments.