Skip to content
RCE Write-up Advanced

CVE-2021-27076: A Replay-Style Deserialization Attack Against SharePoint

SharePoint's InfoPath functionality stored serialized documents in session state and later deserialized them with BinaryFormatter. By manipulating session keys, an attacker could replay an uploaded attachment into the deserialization code path, achieving remote code execution.

Simon Zuckerbraun Follow

Published on thezdi.com

An attacker is frequently in the position of having to find a technique to evade some data integrity measure implemented by a target. One instructive example of a data integrity measure is a message authentication check.

Simon Zuckerbraun (@HexKitchen), on thezdi.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 application used the same session state store for two different purposes (attachment upload and document deserialization) and allowed the client to choose which session key was used, so data stored with one intent could be replayed into the other.

Impact

An attacker could achieve remote code execution on the SharePoint server.

What the attacker needed

Access to a SharePoint site with InfoPath lists; Ability to create list items and attach files; No authentication beyond normal user access

The fix

Microsoft patched this vulnerability in March as CVE-2021-27076.

How it was found

  1. Create an InfoPath list.
  2. Begin adding a new item to the list.
  3. Attach a file containing a fake DocumentSessionState with arbitrary objects, without saving the form.
  4. Scrape the document's state key from the page's HTML.
  5. Feed the document's state key to FormServerAttachments.aspx to replay the DocumentSessionState into the attachment mechanism.
  6. Extract the attachment's state key from the returned data and feed it into an undocumented client-side API to replay the attachment into the deserialization mechanism.

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 a Microsoft product for sharing documents. It saved some data in a temporary store called session state, and later turned that data back into objects in memory. An attacker found a way to make SharePoint save a malicious file in that store and then trick it into loading that file as if it were trusted data, which let them run their own 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 from Microsoft

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.