Skype for Business Audit Part 1 - SKYPErsistence
The Skype for Business web application uses a session cookie handler that deserialises untrusted data with BinaryFormatter after applying cryptographic transforms. An attacker who has compromised the server and obtained its signing certificate can craft a malicious cookie that leads to remote code execution.
Published on frycos.github.io
In this blog post I’ll introduce the first of two findings affecting the latest patched version of Skype for Business 2019. Here, we talk about a tool for Red Teams helping to achieve persistence on a Skype server with help of a (hopefully) new method.
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 SessionSecurityTokenHandler deserialises cookie data with BinaryFormatter after only cryptographic transforms, allowing a gadget chain to execute code.
Impact
An attacker who has already compromised the Skype server and exported its signing certificate could achieve remote code execution on both internal and external worker processes.
What the attacker needed
Compromised Skype server; exported signing certificate; modified ysoserial.NET plugin
How it was found
- Browse to the PassiveAuth endpoint and attach the IIS worker process to a .NET debugger.
- Inspect Web.config and identify the SessionAuthenticationModule.
- Export the Skype service signing certificate from the local machine store.
- Modify the ysoserial.NET SessionSecurityTokenHandler plugin to apply the deflate, RSA encryption and RSA signature transforms with the exported certificate.
- Generate the payload and send it as the FedAuth cookie.
- Observe code execution when the server deserialises the cookie.
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.
The web server reads a cookie called FedAuth and turns its contents back into an object without checking that the data is safe. If an attacker can sign the cookie with the server's own certificate, they can make the server run their code. This only matters after the server is already compromised, because the attacker needs that certificate.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.