Chains on Chains: Chaining multiple low-level vulns into a Critical.
A blind XSS vulnerability on a PHP endpoint was combined with a CSP bypass to steal a session cookie that lacked HttpOnly and Secure flags. The stolen cookie was then used to obtain a non-expiring JWT from a hidden endpoint, granting access to sensitive data and the ability to make payments on the victim's behalf.
Published on medium.com
Hello! Hope all is well.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
The target was an application that provides an online service directory connecting consumers to local businesses in the home improvement trade industry. The program also had a separate, newer feature aimed at government entities. In the write-up the app is referred to as https://www.work.com.
The chain described here does not rely on a single severe bug. It combines several low to medium issues: a session cookie without security flags, a blind XSS that had to get past a Content Security Policy, a hidden PHP file that hands out non-expiring JWTs, missing rate limiting that made content discovery easy, and sensitive information disclosure. Each one on its own is modest; together they let the researcher take over a victim's session and then act on the victim's behalf with a token that never expires.
Setup
The researcher worked with two roles in the application: a "consumer" account and a "worker" account. He used the app as intended in both roles for a couple of hours and noted anything interesting to avoid going down a rabbit hole.
Tools used:
- Wappalyzer (Chrome extension) for fingerprinting, which identified the app as written in PHP.
- Burp Proxy history for reviewing traffic, and Burp for replaying requests.
- GAU (https://github.com/lc/gau) to look for endpoints that had been cached and that he had not come across himself.
- Parameter brute forcing against a discovered endpoint.
- A blind XSS (BXSS) listener URL to receive the exfiltrated data.
Finding it
While reviewing Burp Proxy history at the end of the day, the researcher noticed that the session cookie did not carry the HttpOnly or Secure flag. That alone is a reportable finding, but he chose to push it further: without HttpOnly, JavaScript can read document.cookie, so any XSS on the application becomes a session theft primitive.
During the same session he located an AJAX directory containing PHP files of the form:
https://work.com/api/ajax/dir/file.php
He fuzzed that PHP endpoint for other PHP files and found a hidden file called JWT.php. Calling it returned a JWT token, similar to the token used for certain API calls, and that token did not expire. Interesting, but not worth reporting on its own yet.
Exploitation
Step 1: Look for an XSS to read the cookie
With a cookie that JavaScript can read, the plan was to find an XSS and call document.cookie. He had already reported a different XSS on the program the day before and did not want to reuse it. He went through every endpoint he had seen that took a parameter, with no luck, and did some content discovery for new assets, again with no luck.
Step 2: Find a forgotten endpoint with GAU
He ran GAU to see whether any cached endpoints existed that he had not encountered. That surfaced:
https://work.com/dir/app-detection.php
The page was still live but, on its own, useless. He brute forced parameter names against the endpoint and found a parameter that was vulnerable to XSS. He threw in a payload and was immediately stopped by the Content Security Policy.
Step 3: Bypass the CSP with an iframe srcdoc
To get around the CSP he injected an iframe and used the srcdoc attribute. The HTML supplied as the value of srcdoc is executed, so he placed a script there that made a call to his BXSS URL. That gave him the victim's session token.

Step 4: Look for sensitive endpoints that accept the session token
Back in Burp he searched for endpoints that both exposed sensitive information in the response body and used the session token. He found some interesting sensitive information, but nothing that would justify maximum severity.
Step 5: Swap the stolen cookie into the JWT endpoint
He then returned to the JWT.php file found during recon. He put that endpoint into Burp, replaced the session cookie with the victim's stolen cookie, and received a JSON web token issued on behalf of the victim that does not expire. With that token he explored the application and, as expected, could reach much more sensitive data belonging to the victim. If the victim had been a government asset, he would have been able to see highly sensitive documents uploaded to the app. He could also generate a payment JSON web token and make payments on behalf of the victim.
Root cause
The chain depends on several separate weaknesses, each of which the report lists explicitly:
- Lack of proper security flags on cookies. Without
HttpOnly, any XSS can read the session cookie; withoutSecure, the cookie can travel over plain HTTP. - A blind XSS on a forgotten endpoint (
app-detection.php), reachable through a parameter found by brute force, with a CSP that could be bypassed using an iframesrcdoc. - A hidden PHP file (
JWT.php) that generates JWT tokens from a session, and those tokens do not expire. - Lack of rate limiting, which made content discovery and parameter brute forcing easy.
- Sensitive information disclosure in endpoints that accept the session token or the JWT.
The chain combines a non-expiring token with a token-generation endpoint that accepts a session cookie. Once the cookie is stolen, the attacker converts it into a token that does not expire.
Impact
An attacker who can get the XSS to fire in a victim's browser can read the session cookie and then exchange it for a non-expiring JWT for that victim. With the JWT the attacker can access sensitive data belonging to the victim. If the victim is a government entity, that includes highly sensitive documents uploaded to the app. The attacker can also generate a payment JWT and make payments on behalf of the victim. The report does not state which users or roles were tested beyond the consumer and worker accounts, nor how the XSS was delivered to a victim in practice.
Fix
The report does not say what the program changed. Based on the weaknesses it lists, the fixes would be: set HttpOnly and Secure on session cookies; fix the XSS on app-detection.php and tighten the CSP so that srcdoc cannot be used to execute injected HTML; remove or properly protect JWT.php so that it cannot be used to mint tokens from a session alone; give issued JWTs an expiry and a revocation path; add rate limiting to content discovery and parameter brute forcing; and review the endpoints that returned sensitive data for proper authorisation checks.
Variants to test
- Check session cookies for missing
HttpOnlyandSecureflags, then look for any reflected, stored or blind XSS on the same origin. A positive result is JavaScript readingdocument.cookieand the value arriving at your listener. - Run GAU or a similar cache-based source against the target and test forgotten endpoints such as
*-detection.phpstyle pages. A positive result is a live endpoint that still processes parameters. - Brute force parameter names on old endpoints. A positive result is a parameter whose value is reflected into the response.
- When a CSP blocks your payload, try an iframe with a
srcdocvalue containing a script. A positive result is the script executing and your listener receiving a callback. - Fuzz PHP directories for hidden files with names like
JWT.php,token.phporauth.php. A positive result is an endpoint that returns a token. - Take a token from such an endpoint and check whether it expires. A positive result is a token that does not expire.
What happened, in plain words
A security researcher spent a day using a website the way a normal customer would, then looked at the traffic his browser had sent and received. He found a handful of small mistakes in how the site was built. None of them was dramatic on its own. But he was able to connect them, one after another, like links in a chain, until the combined result was serious: he could take over another person's logged-in session and then keep acting as that person with a credential that never expires.
The site was an online directory that connects ordinary consumers with local businesses in the home improvement trade. It also had a newer section aimed at government entities. In the write-up the site is called https://www.work.com.
The five small mistakes were:
- The cookie that identifies a logged-in user was missing two protective settings, so any script running on the page could read it.
- A forgotten page accepted input that let an attacker run their own script in a victim's browser (a cross-site scripting bug), and the site's defences against such scripts could be worked around.
- A hidden file on the server handed out a special kind of access token, and those tokens never expired.
- The server did not limit how many requests someone could send, so guessing file names and parameter names was easy.
- Some pages returned sensitive information to whoever held a valid session or token.
This article walks through the same steps the researcher took, in the same order, explaining each idea from scratch.
The target and the roles
The application is a service directory. Think of it as a noticeboard: consumers post what they need, workers (the tradespeople) offer their services, and the site sits in the middle. There is also a separate feature for government entities.
The researcher created two accounts: one as a "consumer" and one as a "worker". He then used the app normally in both roles for a couple of hours. This is deliberate: before attacking anything, you want to understand what the app is supposed to do, so you can spot what it does that it should not. He wrote down anything that looked interesting so he would not get lost later.
The tools, and what each one is for
- Wappalyzer, a browser extension, looks at a website and guesses what technology built it (the programming language, the web server, the libraries). This is called fingerprinting. It told him the app was written in PHP, a popular language for building websites.
- Burp Proxy sits between your browser and the website and records every request and response. A request is what your browser sends ("please give me this page"); a response is what the server sends back. Burp lets you read that history and replay or modify requests by hand.
- GAU (GetAllUrls, at https://github.com/lc/gau) collects web addresses that have been seen before in public archives and other sources. It is a way to find pages that still exist on a site but that nobody links to any more.
- Parameter brute forcing means trying a long list of possible names for an input field (a "parameter") until one of them does something.
- A blind XSS listener is a small service the researcher controls. His injected script calls out to it, and the service records the call. "Blind" means the attacker cannot see the result in his own browser; he only learns it worked when the call arrives at his listener.
Step 1: A cookie without its safety settings
At the end of the day the researcher was reading through his Burp history and noticed something about the session cookie.
A cookie is a small piece of text that a website asks your browser to store and to send back with every request to that site. The session cookie is the important one: it is the site's way of recognising you. After you log in, the server gives your browser a session cookie, and on every later request the browser shows it, like a wristband at an event that proves you already paid to get in.
Two settings can be attached to a cookie:
- HttpOnly means JavaScript running in the page is not allowed to read the cookie. It is a lock on the wristband so that a script cannot copy it.
- Secure means the browser will only send the cookie over an encrypted (HTTPS) connection, so it cannot be read off the wire in plain text.
The session cookie here had neither. The researcher could have reported just that and earned a small reward, but he decided to see how far he could take it. The reason is simple: without HttpOnly, any JavaScript that manages to run on the site can read document.cookie, which is the browser's built-in way for a script to read the site's cookies. So if he could get a script of his own to run in a victim's browser, he could read the victim's session cookie and then use it himself.
Step 2: A hidden directory of PHP files
While exploring, he found a folder used by the site's background requests (AJAX, which is how a page fetches data without reloading). It contained PHP files with addresses like:
https://work.com/api/ajax/dir/file.php
Line by line:
https://work.comis the site./api/ajax/dir/is the folder. "API" means an interface meant for programs rather than people: the page's own JavaScript calls it to fetch data.file.phpis one file in that folder. PHP files are scripts that run on the server and produce a response.
He then tried many other file names in that same folder (fuzzing) and found one that was not linked anywhere: JWT.php. When he requested it, the server simply returned a JWT.
A JWT (JSON Web Token) is a compact string that a server issues to prove who you are, a bit like a stamped ticket. Unlike a session cookie, which the server looks up in its own records, a JWT carries its own proof inside it, and the server can check the stamp without looking anything up. The token he received looked like the ones used for certain API calls, and, importantly, it did not expire. He noted it as interesting but did not report it yet, because on its own it was not clearly a vulnerability.
Step 3: Looking for a cross-site scripting bug
His plan was to steal a session cookie. To do that he needed a way to run his own JavaScript in a victim's browser. That class of bug is called cross-site scripting, or XSS: the site takes something a user supplies and puts it into a page in a way that the browser treats as code instead of text. If an attacker can get a victim to load a page containing the attacker's script, the script runs with the site's permissions and can read the site's cookies.
He had already reported a different XSS on this program the day before and did not want to reuse it. So he went through every page he had seen that accepted an input (a parameter, the part of a web address after a ? that carries a value) and tried to make each one echo something back. No luck. He also did some content discovery, guessing at file and folder names to find pages nobody had linked, again with no luck.
Step 4: GAU finds a forgotten page
He then ran GAU to see whether any addresses for this site had been cached elsewhere on the internet that he had not come across himself. That turned up:
https://work.com/dir/app-detection.php
Line by line:
https://work.comis the site./dir/is a folder.app-detection.phpis a page that, judging by its name, was used to detect something about the visitor's app or browser.
The page was still live but, on its own, did nothing useful. So he tried many possible parameter names against it. One of them turned out to be vulnerable to XSS: whatever value he put in was placed into the page in a way the browser would execute. He sent a test payload and was immediately blocked by the site's Content Security Policy.
A Content Security Policy (CSP) is a set of rules the site sends to the browser saying which sources of script are allowed to run. It is like a guest list at a door: even if someone sneaks a script onto the page, the browser refuses to run it unless its source is on the list. This is exactly the defence that stops a simple XSS from working.
Step 5: Getting around the CSP with an iframe
To get past the CSP he injected an iframe and used its srcdoc attribute. An iframe is a page inside a page, a small window embedded in the current document. The srcdoc attribute lets you supply the entire contents of that inner page as text. The browser then renders that HTML, and any script inside it runs.
The trick is that the inner page is treated as its own document, so the CSP rules that applied to the outer page do not automatically stop the script inside srcdoc. He put a script there that made a call to his blind XSS listener. When the payload fired in a victim's browser, the script ran, read the victim's session cookie, and sent it out to the listener. That gave him the victim's session token.

Step 6: Looking for pages that leak data to a session holder
Back in Burp, he searched for pages that both returned sensitive information in the response and accepted the session cookie. He found some interesting data, but nothing that would justify the highest severity on its own. The point of this step is to see what a stolen session is actually worth before deciding how to report it.
Step 7: Turning the stolen cookie into a token that never expires
He then went back to the JWT.php file he had found during recon. He put that address into Burp, replaced the session cookie with the victim's stolen cookie, and the server returned a JSON web token issued on behalf of the victim. That token does not expire.
This is the step that turns a temporary theft into a lasting one. A session cookie can be ended: the victim logs out, or the site expires the session, and the stolen cookie stops working. A token that never expires does not have that escape hatch. It is like copying a key that the building can never change the lock for.
With that token he explored the application and, as expected, could reach much more sensitive data belonging to the victim. If the victim had been a government entity, he would have been able to see highly sensitive documents uploaded to the app. He could also generate a payment JSON web token and make payments on behalf of the victim.
Why the chain works
The chain depends on several separate weaknesses, each of which the report lists explicitly:
- Missing cookie flags. Without HttpOnly, any XSS can read the session cookie; without Secure, the cookie can travel over plain HTTP.
- A blind XSS on a forgotten page.
app-detection.phpaccepted a parameter found by brute force, and the CSP could be bypassed with an iframesrcdoc. - A hidden token factory.
JWT.phpgenerates JWT tokens from a session, and those tokens do not expire. - No rate limiting. Content discovery and parameter brute forcing were easy because the server did not slow down or block repeated requests.
- Sensitive information disclosure. Pages that accept the session token or the JWT returned data they should not have.
The design mistake that turns the small issues into a critical one is the combination of a non-expiring token with a token-generation endpoint that accepts a session cookie. Once the cookie is stolen, the attacker converts it into a token that does not expire.
What an attacker could do
An attacker who can get the XSS to fire in a victim's browser can read the session cookie and then exchange it for a non-expiring JWT for that victim. With the JWT the attacker can access sensitive data belonging to the victim. If the victim is a government entity, that includes highly sensitive documents uploaded to the app. The attacker can also generate a payment JWT and make payments on behalf of the victim. The report does not state which users or roles were tested beyond the consumer and worker accounts, nor how the XSS was delivered to a victim in practice.
How it should be fixed
The report does not say what the program changed. Based on the weaknesses it lists, the fixes would be: set HttpOnly and Secure on session cookies; fix the XSS on app-detection.php and tighten the CSP so that srcdoc cannot be used to execute injected HTML; remove or properly protect JWT.php so that it cannot be used to mint tokens from a session alone; give issued JWTs an expiry and a revocation path; add rate limiting to content discovery and parameter brute forcing; and review the pages that returned sensitive data for proper authorisation checks.
Things to try on your own targets
- Check session cookies for missing HttpOnly and Secure flags, then look for any reflected, stored or blind XSS on the same site. A positive result is JavaScript reading
document.cookieand the value arriving at your listener. - Run GAU or a similar cache-based source against the target and test forgotten pages such as
*-detection.phpstyle pages. A positive result is a live page that still processes parameters. - Brute force parameter names on old pages. A positive result is a parameter whose value is reflected into the response.
- When a CSP blocks your payload, try an iframe with a
srcdocvalue containing a script. A positive result is the script executing and your listener receiving a callback. - Fuzz PHP folders for hidden files with names like
JWT.php,token.phporauth.php. A positive result is a page that returns a token. - Take a token from such a page and check whether it expires. A positive result is a token that does not expire.
Glossary
- AJAX: a way for a web page to fetch data from the server in the background, without reloading the whole page.
- API: an interface meant for programs to talk to each other, rather than for a person clicking around.
- Blind XSS: a cross-site scripting bug where the attacker cannot see the result in his own browser and only learns it worked when his script calls back to a listener he controls.
- Brute forcing: trying a long list of possible names or values until one works.
- Burp Proxy: a tool that sits between your browser and a website, recording and letting you modify the requests and responses.
- Content Security Policy (CSP): rules a site sends to the browser saying which sources of script are allowed to run.
- Cookie: a small piece of text a site asks your browser to store and send back with each request, used to recognise you.
- Cross-site scripting (XSS): a bug where a site puts user-supplied input into a page in a way the browser treats as code, letting an attacker run their own script.
- Fingerprinting: working out what technology a site is built with by looking at its responses.
- Fuzzing: sending many variations of a request automatically to find ones that behave differently.
- GAU: a tool that collects web addresses seen in public archives, useful for finding forgotten pages.
- HttpOnly: a cookie setting that stops JavaScript from reading the cookie.
- HTTPS: the encrypted version of the protocol browsers use to talk to websites.
- Iframe: a page embedded inside another page.
- JavaScript: the programming language browsers run to make pages interactive.
- JWT (JSON Web Token): a compact string a server issues to prove who you are, carrying its own proof inside it.
- Parameter: the part of a web address after a
?that carries a value into the page. - PHP: a programming language commonly used to build websites on the server side.
- Rate limiting: a server-side limit on how many requests a client can send in a given time.
- Request / response: what your browser sends to a server, and what the server sends back.
- Secure (cookie flag): a cookie setting that makes the browser send the cookie only over HTTPS.
- Session: the period during which a site recognises you as logged in, tracked by a session cookie.
- Session cookie: the cookie that proves you are logged in.
- srcdoc: an iframe attribute that supplies the entire contents of the inner page as text.
- Token: a string that proves an identity or permission, often used instead of a password for programmatic access.
- Wappalyzer: a browser extension that fingerprints the technology behind a website.