Skip to content
RCE Write-up Advanced

Cloudflare Pages, part 1: The fellowship of the secret

Cloudflare Pages build environments had multiple command injection and privilege escalation flaws, allowing an attacker to execute arbitrary commands and access sensitive secrets such as GitHub private keys and Cloudflare API tokens. This could lead to read and write access to all 18,290 users' repositories connected to Cloudflare Pages.

Sean Yeoh Follow

Published on assetnote.io

Before we get into this lengthy post, we’d like to thank both Cloudflare and HackerOne for working with us on these vulnerabilities. The process of reporting, remediating and validating these problems was undertaken with the utmost professionalism and diligence by all parties.

Sean Yeoh (@seanyeoh), James Hebden (@devec0), on assetnote.io

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, user-controlled build settings (root directory and output directory) were passed unsafely into shell commands, and overly permissive file permissions and PATH entries allowed privilege escalation.

Impact

An attacker could gain read and write access to all 18,290 users' repositories that had granted Cloudflare Pages access, and access Cloudflare's internal API tokens.

What the attacker needed

A Cloudflare Pages account; ability to set build configuration; victim has connected a repository

The fix

The issues were fixed by adding server-side validation, escaping arguments, scoping tokens, restricting permissions, and using absolute paths.

How it was found

  1. Set a malicious root directory via the Cloudflare Pages UI or API, bypassing client-side validation.
  2. Trigger a build so the injected command runs and dumps environment variables.
  3. Use the leaked GitHub private key to access repositories via the GitHub API.
  4. Exploit a world-writable binary to regain access after the first fix.
  5. Hijack the PATH by creating a malicious bash binary in a writable directory.

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.

Cloudflare Pages is a service that builds and hosts websites from code repositories. The build process ran user-supplied commands without properly checking them, so an attacker could sneak in extra commands to steal secret keys. Those keys then gave access to many users' code repositories.

What is RCE?

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

More from Cloudflare

View all

The newest disclosed reports for this program.

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.