Skip to content
RCE Write-up Advanced

Exploiting ASP.NET TemplateParser — Part II: SharePoint (CVE-2023-33160)

SharePoint's page parser filter only checked the outer type of a server control against its Safe Controls list, so a generic type whose type argument was an unsafe type could slip through. An attacker who could upload an ASPX page could then reach a dangerous type and its converter or parse method, leading to remote code execution.

Markus Wulftange Follow

Published on code-white.com

In Part I, we dug into the internals of the ASP.NET TemplateParser and elaborated its capabilities in respect to exploitation.

Markus Wulftange (@mwulftange), on code-white.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 the Safe Controls validation only inspected the outer control type and did not recursively validate the generic type arguments, and a null character in the namespace truncated the appended type name.

Impact

An attacker able to upload a crafted page could bypass the Safe Controls restriction and achieve remote code execution; the exact exploit chain is not published.

What the attacker needed

Ability to upload or create ASPX pages; SharePoint on-premises or Online

The fix

Microsoft addressed the bypass (CVE-2023-33160); the text does not describe the fix.

How it was found

  1. Register a server control whose namespace ends with a null character so the appended type name is ignored.
  2. Use a generic wrapper type whose type argument is the targeted dangerous type.
  3. Set a property on the control so the target type's converter or parse method is invoked.
  4. Upload the page to SharePoint so the parser processes it.

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 is supposed to block pages that run server-side code by only allowing approved controls. The check looked at the main control name but not the extra type inside a generic control, so a crafted page could sneak a forbidden type past the check and potentially 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.

More by Markus Wulftange

View all

25 more disclosed reports, best first.

More from Microsoft (Sharepoint)

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.