CVE-2021-26420: Remote Code Execution in SharePoint via Workflow Compilation
SharePoint's authorizedTypes list blocked the WorkflowCompiler type, but the internal WorkflowCompilerInternal class was not blocked, allowing an authenticated user with Manage Lists permissions to compile an arbitrary workflow and execute .NET code on the server. The attacker could run arbitrary OS commands in the context of the SharePoint web application account.
In June of 2021, Microsoft released a patch to correct CVE-2021-26420 – a remote code execution bug in the supported versions of Microsoft SharePoint Server. This bug was reported to the ZDI program by an anonymous researcher and is also known as ZDI-21-755.
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 authorizedTypes blocklist in web.config blocked the public WorkflowCompiler type but not the internal WorkflowCompilerInternal class that performs the actual compilation, so the restriction could be bypassed by calling the internal class directly.
Impact
An authenticated user with Manage Lists permissions could execute arbitrary .NET code and OS commands in the context of the SharePoint web application service account; the attacker also needed an SMB share they control, which adds complexity.
What the attacker needed
Authenticated SharePoint user; Manage Lists permission on a site; attacker-controlled SMB share reachable by server
The fix
Microsoft patched this in June 2021 as CVE-2021-26420.
How it was found
- Log in as a regular user and create a new site where the user is owner.
- Create a new list and note its ListID from the listedit.aspx page.
- Place the ListID into the workflow config file and the remote path to the malicious XOML file into the rules file.
- Upload the config, rules and XOML files to the Documents folder of the site.
- Use the WebPartPages web service AssociateWorkflowMarkup method to associate the workflow with the list.
- Add a new item to the list to trigger workflow execution and code execution.
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.
SharePoint lets users build small automated helpers called workflows. The server tries to stop workflows from running dangerous code by keeping a blocklist of forbidden types, but the blocklist missed an internal helper class that does the actual compiling. By calling that missed class, a logged-in user could make the server run their own code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.