Skip to content
Path traversal Write-up Advanced

Cloudflare's Handling of an RCE Vulnerability in Cdnjs

A vulnerability in cdnjs's auto-update pipeline allowed an attacker to publish a malicious npm package containing a symbolic link, which when extracted could overwrite local files and execute arbitrary code. This gave the attacker the ability to modify assets served by cdnjs.

blog.cloudflare.com

Published on blog.cloudflare.com

cdnjs provides JavaScript, CSS, images, and fonts assets for websites to reference with more than 4,000 libraries available. By utilizing cdnjs, websites can load faster with less strain on one’s own origin server as files are served directly from Cloudflare’s edge.

The author, on blog.cloudflare.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

The auto-update pipeline extracted npm packages without properly checking for path traversal via symbolic links, and the extraction process ran with excessive privileges.

Impact

The attacker could execute arbitrary code and modify assets, but no existing libraries were modified and the integrity of all assets remained intact.

What the attacker needed

Ability to publish to npm; cdnjs auto-update enabled for the package

The fix

The path traversal was fixed by canonical path checks, an AppArmor profile was added, and the pipeline was redesigned to use isolated Docker containers.

How it was found

  1. Publish a malicious package to npm containing a .tar.gz archive with a symbolic link.
  2. cdnjs's auto-update service processes the package and extracts the archive.
  3. The extraction follows the symlink and overwrites local files with the attacker's content.
  4. The attacker gains code execution and can modify assets.

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.

The cdnjs service automatically updates libraries from npm. An attacker could upload a specially crafted package that, when processed, would let them run their own code on the server. This could let them change the files that websites load from cdnjs.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.