Alright, let's talk about a bug that sounds boringβ¦ but can actually be π₯ very spicy in bug bounty programs β CSPT (Client-Side Path Traversal).
If you've ever thought "Path traversal is just ../../etc/passwd, right?" β yeahβ¦ that's server-side. CSPT is its sneaky cousin that lives in the browser and quietly causes chaos π
π§ What is CSPT?
Client-Side Path Traversal (CSPT) happens when JavaScript running in the browser constructs URLs using user-controlled input, without proper sanitization.
π Instead of the server resolving paths, the browser builds and sends unintended requests.
π‘ Simple idea:
The app thinks it's requesting:
/api/users/profileBut you trick it into requesting:
/api/admin/secretsAnd boom π₯ β unintended access.
βοΈ How CSPT Happens
Most modern apps use JavaScript like this:
fetch(`/api/${endpoint}`)Looks innocent, right? π
But if endpoint is user-controlledβ¦
endpoint = "../../admin/secrets"Now the browser requests:
/api/../../admin/secretsWhich resolves to:
/admin/secretsπ― Congrats β you just bypassed intended API structure.
πͺ Step-by-Step Exploitation
1οΈβ£ Find a dynamic request
Look for places where JS builds URLs:
fetch(`/api/posts/${postId}`)2οΈβ£ Check if input is controllable
Can you control postId via:
- URL parameters
- Hash fragments
- Input fields
- Local storage
Example:
https://target.com/?postId=1233οΈβ£ Inject traversal payload
Try:
../../adminSo request becomes:
/api/posts/../../adminBrowser resolves it to:
/adminπ Sneaky, right?
π₯ Real Example
Original JS:
const file = new URLSearchParams(location.search).get("file");
fetch(`/static/${file}`);You send:
?file=../../api/admin/usersBrowser sends request:
/static/../../api/admin/usersβ‘οΈ Final request:
/api/admin/usersπ You just accessed an internal API!
π Why CSPT is Dangerous
CSPT alone is coolβ¦ but chained? Chef's kiss π¨βπ³π
π Attack chains:
1. Access Hidden APIs
Endpoints not exposed in UI suddenly become reachable.
2. Bypass Frontend Restrictions
Frontend says:
"You are not admin π‘R&quo;
But CSPT says:
"I go where I want πR&quo;
3. Steal Sensitive Data
If responses are readable:
- user data
- tokens
- configs
4. Combine with CORS Misconfig
If CORS is weak: π Data exfiltration becomes possible.
5. Abuse SSRF-like behavior
You may trick frontend into calling internal endpoints.
π§ͺ Testing Tips (Bug Hunter Mode π΅οΈββοΈ)
π Where to look:
fetch()axios()XMLHttpRequest- Dynamic imports
- File loaders
π₯ Payloads to try:
../../
../../../
..%2f
..%252fπ§ Pro Tip:
Always check:
- Network tab (DevTools) π
- See actual requests being sent
π§© CSPT vs Server-Side Path Traversal
FeatureCSPTServer-sideRuns inBrowserServerImpactAPI abuseFile accessVisibilityEasy (DevTools)HiddenExploit styleURL manipulationFile system traversal
π‘οΈ How to Fix (for devs lurking π)
β Bad:
fetch(`/api/${userInput}`)β Good:
- Validate input strictly
- Use allowlists:
const allowed = ["profile", "posts"];
if (!allowed.includes(userInput)) return;- Avoid direct concatenation
π Final Thoughts
CSPT is like:
"Frontend said noβ¦ but browser said yes πR&quo;
It's often overlooked because:
- It's not "classic"
- It lives in JavaScript
- People underestimate frontend bugs
But in bug bountyβ¦ π We don't ignore weird bugs. We weaponize them π