CVE-2021-28474: SharePoint Remote Code Execution via Server-Side Control Interpretation Conflict
SharePoint's security check for unsafe server controls did not HTML-decode attribute values, while the later processing step did, so an attacker could bypass the safe-control list and execute arbitrary .NET code. An authenticated user with ManageLists permissions could exfiltrate the machineKey and forge a ViewState to achieve remote code execution.
zerodayinitiative.com
Published on zerodayinitiative.com
In May of 2021, Microsoft released a patch to correct CVE-2021-28474, a remote code execution bug in supported versions of Microsoft SharePoint Server. This bug was reported to ZDI by an anonymous researcher and is also known as ZDI-21-574.
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 verification code did not HTML-decode attribute values before checking them against the safe-control list, while the processing code did decode them, creating a parser differential.
Impact
An authenticated user with ManageLists permissions could execute arbitrary .NET code on the server in the context of the SharePoint service account, leading to remote code execution.
What the attacker needed
Authenticated SharePoint user; ManageLists permissions (default for site creators); ability to send SOAP requests
The fix
Microsoft patched the vulnerability in May 2021.
How it was found
- Authenticate to SharePoint as a regular user and create a site to obtain ManageLists permissions.
- Find a relative path to an existing site page, such as SitePages/Home.aspx.
- Send a SOAP request to the WebPartPagesWebService.ExecuteProxyUpdates endpoint with a crafted OuterHtml attribute that uses an HTML-encoded runat attribute to bypass the safe-control check.
- Retrieve the machineKey section from web.config, including the validationKey and validation algorithm.
- Obtain the __VIEWSTATEGENERATOR value from a page on the site.
- Generate a malicious ViewState using ysoserial with the stolen validationKey and send it as the __VIEWSTATE parameter to achieve 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 add content to pages, and it tries to block dangerous server-side controls by checking a list of allowed controls. The check looked at the raw text, but the actual processing decoded special characters first, so a control could sneak past the check. An attacker with a normal account could then run code 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.