Skip to content
Race condition Write-up Advanced

FabricScape: Escaping Service Fabric and Taking Over the Cluster

A race condition in Service Fabric's Data Collection Agent allowed a container with runtime access to overwrite arbitrary files on the node as root, leading to container escape and cluster takeover via a stolen certificate.

Unit42_Intel Follow

Published on unit42.paloaltonetworks.com

Unit 42 researchers identified FabricScape (CVE-2022-30137), a vulnerability of important severity in Microsoft’s Service Fabric – commonly used with Azure – that allows Linux containers to escalate their privileges in order to gain root privileges on the node, and then compromise all of the nodes in the cluster. The…

Aviv Sasson, on unit42.paloaltonetworks.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 a time-of-check to time-of-use race condition: the agent read a file, then later wrote to the same path without ensuring it was still the same file, allowing a symlink to be swapped in.

Impact

An attacker with a compromised container that has runtime access could gain root on the node and then take over the entire cluster; however, this only works if runtime access is enabled, and Microsoft disabled it on multi-tenant offerings.

What the attacker needed

Compromised container with runtime access; Linux node (Windows not exploitable); ability to create files in log directory

The fix

Microsoft released a patch that mitigated the issue in Linux clusters, and customers without automatic updates should upgrade to the latest Service Fabric release.

How it was found

  1. Create a file named ProcessContainerLog.txt in the container's log directory to trigger the vulnerable function.
  2. Make the file large (10 MB) so parsing takes time, then replace it with a symlink to a target file on the node.
  3. Use the arbitrary write to overwrite /etc/environment with malicious environment variables.
  4. Place a shared object in the log directory and set LD_PRELOAD to point to it.
  5. Wait for a root cron job to execute, which loads the shared object and runs a reverse shell.
  6. Use the root access to read the cluster certificate from /var/lib/waagent/ and authenticate to the cluster API.

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.

Service Fabric is a system for running many applications across a cluster of machines. Each application runs in a container, which is like a lightweight virtual machine. A flaw in a background service that collects logs let a malicious container write files anywhere on the host machine as the all-powerful root user, so the attacker could break out of the container and control the whole cluster.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by Unit42_Intel

View all

2 more disclosed reports, best first.

More from Microsoft

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.