Skip to content
RCE Write-up Intermediate

Hidden Dangers in Less.js: XSS, SSRF, and Remote Code Execution

Less.js, a CSS preprocessor, allows inline JavaScript execution in versions before 3.0.0 and supports plugins and imports that can be abused. An attacker who can supply Less code could achieve cross-site scripting, server-side request forgery, local file disclosure, or remote code execution, depending on configuration.

softwaresecured.com

Published on softwaresecured.com

Less.js is widely used as a CSS preprocessor, but under certain configurations it becomes far more than a styling tool. In this deep-dive, we demonstrate how legacy inline JavaScript execution, unrestricted @import behavior, and plugin support can be chained into XSS, SSRF, local file disclosure, and even full remote…

The author, on softwaresecured.com

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

Root cause

Likely the root cause is that Less.js processes user-supplied code without sufficient restrictions, allowing inline JavaScript execution, remote plugin loading, and unrestricted file or URL imports.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser (XSS), read local files or make server-side requests (SSRF/file disclosure), or execute arbitrary commands on the server (RCE), potentially leading to credential theft and full system compromise.

What the attacker needed

Application accepts user-supplied Less code; Less.js version <3.0.0 for inline JS XSS; server-side transpilation for RCE/SSRF; plugin support enabled for plugin-based attacks

The fix

The issues were fixed in CodePen, and generally Less.js should be configured to disable inline JavaScript, block remote plugins, and restrict imports to an allowlist.

How it was found

  1. Identify an application that accepts user-supplied Less code and transpiles it.
  2. For XSS, supply Less code with inline JavaScript (if version <3.0.0) or a malicious plugin.
  3. For SSRF or file disclosure, use @import (inline) with a local path or URL.
  4. For RCE, supply a Less plugin that executes system commands.

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.

Less.js is a tool that turns special styling code into normal CSS for websites. If a website lets users provide their own Less code, an attacker can include instructions that make the tool run harmful JavaScript or fetch sensitive files. This can lead to stolen data or full control of the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.