CVE-2021–35215 SolarWinds Orion Platform ActionPluginBaseView RCE
字数 1164 2025-08-03 16:47:08

SolarWinds Orion Platform ActionPluginBaseView 反序列化远程代码执行漏洞分析 (CVE-2021-35215)

漏洞概述

CVE-2021-35215是SolarWinds Orion平台中存在的一个反序列化远程代码执行漏洞,位于ActionPluginBaseView组件中。攻击者可以通过构造特定的序列化数据,在目标服务器上执行任意代码。

漏洞分析

漏洞入口点

漏洞位于C:\InetPub\SolarWinds\Orion\RenderControl.aspx.cs文件的OnInit()方法中:

controlToRender = LoadControl(ctrl);  // ctrl从请求中获取,可控
ApplyPropertiesAndAttributes(controlToRender);

controlToRender是一个System.Web.UI.Control类型的控件,从HTTP请求参数中加载。

关键反序列化过程

  1. ApplyPropertiesAndAttributes()方法从JsonData中获取字段名称和值,通过PropertySetter.SetProperties()进行反射赋值:

    // JsonData是从HTTP请求中通过JavaScriptSerializer反序列化的Dictionary<string, object>
    PropertySetter.SetProperties(controlToRender, JsonData);
    
  2. 重点关注的类是SolarWinds.Orion.Web.Actions.ActionPluginBaseView,其setter调用了ParseViewContext()方法:

    public string ViewContextJsonString
    {
        set
        {
            this.ParseViewContext(value);
        }
    }
    
  3. ParseViewContext()方法使用了Json.NET进行反序列化,并设置了TypeNameHandling.Objects

    JsonConvert.DeserializeObject<AlertingActionContext>(this.ViewContextJsonString, settings);
    

反序列化链构造

  1. AlertingActionContext继承自ActionContextBase
  2. ActionContextBase包含MacroContext类型的字段
  3. MacroContext类型包含ContextBase类型的List字段
  4. ContextBase是抽象类,其KnownType允许使用SwisEntityContext类型
  5. SwisEntityContext类包含PropertyBag类型的字段,可以存放Object类型的对象

漏洞利用关键点

  • 通过反射可以调用控件类的setter方法
  • Json.NET的TypeNameHandling.Objects设置允许指定类型信息
  • PropertyBag可以存放任意对象,为恶意对象提供了落脚点

漏洞利用PoC

以下是漏洞利用的关键代码结构:

var alertingActionContext = new AlertingActionContext();
var macroContext = new MacroContext();
var swisEntityContext = new SwisEntityContext();
var dictionary = new Dictionary<string, Object>();

// 在此处放置恶意对象(如SessionSecurityToken gadget)
dictionary["1"] = new Object(); 

var propertyBag = new PropertyBag(dictionary);
swisEntityContext.EntityProperties = propertyBag;
macroContext.Add(swisEntityContext);
alertingActionContext.MacroContext = macroContext;

// 使用TypeNameHandling.Objects进行序列化
JsonSerializerSettings settings = new JsonSerializerSettings
{
    TypeNameHandling = TypeNameHandling.Objects
};
var serializeObject = JsonConvert.SerializeObject(alertingActionContext, settings);

防御建议

  1. 限制或禁用Json.NET的TypeNameHandling功能,或使用更安全的设置如TypeNameHandling.None
  2. 对用户提供的控件名称和JSON数据进行严格验证
  3. 更新到SolarWinds发布的安全补丁版本
  4. 实施输入过滤,防止恶意序列化数据被处理

参考资源

  1. 原始漏洞分析文章
  2. .NET反序列化基础知识
  3. 漏洞PoC代码
SolarWinds Orion Platform ActionPluginBaseView 反序列化远程代码执行漏洞分析 (CVE-2021-35215) 漏洞概述 CVE-2021-35215是SolarWinds Orion平台中存在的一个反序列化远程代码执行漏洞,位于ActionPluginBaseView组件中。攻击者可以通过构造特定的序列化数据,在目标服务器上执行任意代码。 漏洞分析 漏洞入口点 漏洞位于 C:\InetPub\SolarWinds\Orion\RenderControl.aspx.cs 文件的 OnInit() 方法中: controlToRender 是一个 System.Web.UI.Control 类型的控件,从HTTP请求参数中加载。 关键反序列化过程 ApplyPropertiesAndAttributes() 方法从 JsonData 中获取字段名称和值,通过 PropertySetter.SetProperties() 进行反射赋值: 重点关注的类是 SolarWinds.Orion.Web.Actions.ActionPluginBaseView ,其setter调用了 ParseViewContext() 方法: ParseViewContext() 方法使用了Json.NET进行反序列化,并设置了 TypeNameHandling.Objects : 反序列化链构造 AlertingActionContext 继承自 ActionContextBase 类 ActionContextBase 包含 MacroContext 类型的字段 MacroContext 类型包含 ContextBase 类型的List字段 ContextBase 是抽象类,其 KnownType 允许使用 SwisEntityContext 类型 SwisEntityContext 类包含 PropertyBag 类型的字段,可以存放 Object 类型的对象 漏洞利用关键点 通过反射可以调用控件类的setter方法 Json.NET的 TypeNameHandling.Objects 设置允许指定类型信息 PropertyBag 可以存放任意对象,为恶意对象提供了落脚点 漏洞利用PoC 以下是漏洞利用的关键代码结构: 防御建议 限制或禁用Json.NET的 TypeNameHandling 功能,或使用更安全的设置如 TypeNameHandling.None 对用户提供的控件名称和JSON数据进行严格验证 更新到SolarWinds发布的安全补丁版本 实施输入过滤,防止恶意序列化数据被处理 参考资源 原始漏洞分析文章 .NET反序列化基础知识 漏洞PoC代码