Part 2: The two privescs
The Cloudflare Pages build system allowed injection of Azure DevOps Pipeline logging commands via the build command, enabling execution of arbitrary commands as the AzureDevOps user. This led to privilege escalation to root inside the container, container escape via the mounted Docker socket, and access to Cloudflare's Azure DevOps organisation.
assetnote.io
Published on assetnote.io
Following on from our 1st story, we’ll be continuing the epic tale of our research into Cloudflare pages in this second installment. If you haven’t read part 1, you can read it here.
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 build system failed to sanitise user-controlled build settings before interpolating them into Azure DevOps Pipeline variables, allowing injection of logging commands that set variables used in privileged commands.
Impact
An attacker could execute arbitrary commands as the AzureDevOps user, escalate to root in the container, escape to the host, and access Cloudflare's Azure DevOps organisation, including user lists and build history.
What the attacker needed
A Cloudflare Pages account; ability to set build command; Azure DevOps Pipelines used
The fix
Cloudflare rearchitected Cloudflare Pages to not use Azure Pipelines, and additional defences such as restricting logging commands, limiting sudo, and not mounting the Docker socket were recommended.
How it was found
- Add a logging command to the build command in the Cloudflare Pages project settings to set the account_env variable to a reverse shell command.
- Run the build job, which triggers the reverse shell as the AzureDevOps user.
- Use the obtained shell to access the Docker socket and run a privileged container to escape to the host.
- Use the Azure DevOps system access token to query the Cloudflare Pages Azure DevOps organisation.
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 lets you build websites from code. The build system used Azure DevOps Pipelines, which has a feature where special log lines can set variables. The researchers found they could inject such a line through the build command, causing their own script to run with high privileges. This let them take full control of the build server and access Cloudflare's internal systems.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.