Evil CSS injection bug warning: Don't let hackers cross paths with your website

Say hello to a fascinating vulnerability in web scripts

Developers should check their websites for path-relative stylesheet import (PRSSI) vulnerabilities, which can allow miscreants to hijack web pages and steal login cookies, security researchers have urged.

PRSSI flaws were documented by Gareth Heyes early last year; he calls them relative path overwrites. The trick is to lure browsers into importing malicious CSS. Imagine you've found a website with the script:


...which shows a list of threads by their title in a forum. The HTML output of the script contains the line:

<link href="styles.css" rel="stylesheet" type="text/css" />

If you create a forum thread with the title:

Hello world {}*{xss:expression(open(alert(1)))}

...and trick logged-in users into clicking on this link:


...then something rather interesting may happen: the web browser attempts to fetch styles.css by its relative path, which will be /forum/showthreads.php/styles.css rather than what the developer may have expected: /forum/styles.css.

Unless configured otherwise, the web server will return the HTML output of showthreads.php instead of styles.css when the browser tries to fetch that stylesheet. That HTML, a list of forum threads, is useless as a stylesheet, but it does contain your own CSS in one of the thread titles:


This embedded JavaScript, alert(1), is imported and will execute in the context of the logged-in user, popping up a dialog box. Replace that code with something more evil, like something that grabs the session cookie and sends it to a malicious server, and congrats: you've earned a black hat.

Exactly how the injected CSS is formatted will depend on the web browser, it seems. It also depends on how the web server handles PHP scripts and the like.

PortSwigger Web Security, the outfit behind the bug-hunting Burp Suite, warns this class of vulnerability is esoteric in nature and likely missed by software auditors. A blog post by the biz describes a real PRSSI flaw in the popular bulletin board phpBB31 as an example.

PortSwigger, though, is unaware of crooks exploiting PRSSIs in the wild. To stop bad guys and girls exploiting CSS paths, developers are urged to:

  • Avoid using path-relative links
  • Set the server header X-Frame-Options to "deny" on all pages
  • Set the server header X-Content-Type-Options to "nosniff" on all pages
  • Set a modern doctype on all pages

The biz said it published its blog post in order to “explain a vulnerability and attack that is not widely understood, and to give people a means of identifying if they are vulnerable.”

“Someone else invented the core attack technique a few months ago, but we have developed it further and demonstrated its use in real world situations,” Dafydd Stuttard founder and boss of PortSwigger Web Security told El Reg this week.

“This technique is currently quite esoteric, so it’s often effective against sites that have already been subjected to professional or crowdsourced audits. However, successfully exploiting it in a real world environment involves navigating an array of arcane browser internals that often aren't otherwise highly relevant to pen testers.”

Stuttard added: “We aren't aware of any cases of real-world exploitation. We chose that web app as a research target because it is widely used and relatively secure generally. After we reported the bug to the app's authors, we waited for them to fix before using the example to raise awareness. It's likely that lots of live sites are vulnerable, and liable to be targeted as awareness of the issue increases.” ®


1 The phpBB vulnerability in question was patched in version 3.0.13 of the software.

Similar topics

Broader topics

Other stories you might like

  • Experts: AI should be recognized as inventors in patent law
    Plus: Police release deepfake of murdered teen in cold case, and more

    In-brief Governments around the world should pass intellectual property laws that grant rights to AI systems, two academics at the University of New South Wales in Australia argued.

    Alexandra George, and Toby Walsh, professors of law and AI, respectively, believe failing to recognize machines as inventors could have long-lasting impacts on economies and societies. 

    "If courts and governments decide that AI-made inventions cannot be patented, the implications could be huge," they wrote in a comment article published in Nature. "Funders and businesses would be less incentivized to pursue useful research using AI inventors when a return on their investment could be limited. Society could miss out on the development of worthwhile and life-saving inventions."

    Continue reading
  • Declassified and released: More secret files on US govt's emergency doomsday powers
    Nuke incoming? Quick break out the plans for rationing, censorship, property seizures, and more

    More papers describing the orders and messages the US President can issue in the event of apocalyptic crises, such as a devastating nuclear attack, have been declassified and released for all to see.

    These government files are part of a larger collection of records that discuss the nature, reach, and use of secret Presidential Emergency Action Documents: these are executive orders, announcements, and statements to Congress that are all ready to sign and send out as soon as a doomsday scenario occurs. PEADs are supposed to give America's commander-in-chief immediate extraordinary powers to overcome extraordinary events.

    PEADs have never been declassified or revealed before. They remain hush-hush, and their exact details are not publicly known.

    Continue reading
  • Stolen university credentials up for sale by Russian crooks, FBI warns
    Forget dark-web souks, thousands of these are already being traded on public bazaars

    Russian crooks are selling network credentials and virtual private network access for a "multitude" of US universities and colleges on criminal marketplaces, according to the FBI.

    According to a warning issued on Thursday, these stolen credentials sell for thousands of dollars on both dark web and public internet forums, and could lead to subsequent cyberattacks against individual employees or the schools themselves.

    "The exposure of usernames and passwords can lead to brute force credential stuffing computer network attacks, whereby attackers attempt logins across various internet sites or exploit them for subsequent cyber attacks as criminal actors take advantage of users recycling the same credentials across multiple accounts, internet sites, and services," the Feds' alert [PDF] said.

    Continue reading

Biting the hand that feeds IT © 1998–2022