fix(script-analysis): inspect ?. member bindings and CreateDelegate in the trust gate (CMN-1, WP1 task 1.1)
The reflection-gateway check ran only in VisitMemberAccessExpression, so recv?.GetMethod(...) (a MemberBindingExpression) was never inspected and Delegate.CreateDelegate turned the MethodInfo into a callable delegate: one character defeated the trust gate on all four call sites. - HardeningWalker gains VisitMemberBindingExpression with the same check. - CreateDelegate joins ReflectionGatewayMembers. - Pass 1 also flags a gateway-named framework member reached as a bare identifier (using static System.Delegate / System.Type). Tests: the review's probe script (compiles clean, now rejected, also on the minimal fallback set), the ?. variant of every .-form rejection test, every gateway member via ?., and legitimate ?. use stays clean.
This commit is contained in:
@@ -111,6 +111,11 @@ public static class ScriptTrustPolicy
|
||||
"DeclaredMembers",
|
||||
"DeclaredConstructors",
|
||||
"DynamicInvoke",
|
||||
// Code review 2026-12-02 CMN-1: Delegate.CreateDelegate / MethodInfo.CreateDelegate
|
||||
// turn a MethodInfo (obtainable from System.Type, which is not a forbidden scope)
|
||||
// into a directly-callable delegate, so a forbidden method can be invoked without
|
||||
// ever naming a System.Reflection member. No legitimate script use.
|
||||
"CreateDelegate",
|
||||
// DELIBERATELY EXCLUDED: "Invoke". The syntactic pass rejects a gateway
|
||||
// member regardless of receiver, and delegate.Invoke() is a legitimate,
|
||||
// common script pattern (Func<>/Action<> invocation). MethodInfo.Invoke
|
||||
|
||||
Reference in New Issue
Block a user