Bypassing HttpOnly with phpinfo file
A stored cross-site scripting (XSS) vulnerability was found, but the session cookie was protected by the HttpOnly flag, preventing direct theft. The attackers discovered a phpinfo file that displays all cookies, including HttpOnly ones, and used the XSS to make the victim's browser fetch that file and send the cookie to their server, leading to account takeover.
aleksikistauri.medium.com
Published on aleksikistauri.medium.com
Aleksi Kistauri
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
The attackers could steal the HttpOnly session cookie and gain administrator access, escalating privileges from a regular user.
What the attacker needed
Stored XSS vulnerability; phpinfo file accessible; victim visits page with XSS
How it was found
- Find stored XSS in a name field.
- Discover an info.php file that displays all cookies.
- Create JavaScript that uses XMLHttpRequest to fetch info.php and extract the HTTP_COOKIE value.
- Inject the JavaScript payload into the vulnerable name field.
- The victim's browser executes the script, which sends the cookie to the attacker's server.
- Decode the base64-encoded cookie to obtain the ci_session value.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
HttpOnly is a security setting that stops JavaScript from reading a cookie, so even if an attacker can run their own script on a page, they cannot steal the session cookie. Here, the attackers found a separate page (phpinfo) that lists all cookies, including protected ones. They used their script to make the victim's browser load that page and send the cookie back to them, bypassing the protection.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.