Code injection in Workflows leading to SharePoint RCE (CVE-2020-0646)
An attribute of a workflow activity was inserted unescaped into a generated C# source file during compilation, so a crafted workflow markup document could break out of the generated code and run commands on the SharePoint server. The author demonstrated this against SharePoint Online and noted on-premise servers without the January 2020 .NET patch remain affected.
mdsec.co.uk
Published on mdsec.co.uk
Our best in class red team can deliver a holistic cyber attack simulation to provide a true evaluation of your organisation’s cyber resilience.](https://www.mdsec.co.uk/our-services/adversary-simulation/) - [{{media:1}}
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 InterfaceType attribute value was concatenated into generated C# source without validation or escaping, unlike other string attributes such as MethodName.
Impact
An attacker could run arbitrary code on the SharePoint server, and the issue also bypassed the workflow compiler's nocode option; on-premise installations lacking the .NET patch remained vulnerable.
What the attacker needed
Ability to submit workflow markup; unpatched .NET Framework (on-premise)
The fix
The .NET Framework was patched in January 2020 so that all XML elements and attributes in workflows are restricted to a limited set of allowed characters.
How it was found
- Send a request to the SharePoint web part pages SOAP endpoint invoking the workflow markup validation operation.
- Include workflow markup containing a CallExternalMethodActivity whose InterfaceType attribute breaks out of the generated code.
- Observe the injected code executing on the server, for example through an out-of-band DNS lookup.
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 workflows, which are small automated processes described in a markup file. When SharePoint compiles that file it writes some C# code behind the scenes, and one setting from the file was pasted into that code without being cleaned. By putting special characters in that setting, an attacker could make the generated code do something else, such as start a program on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.