Reflection in a .NET assembly is the ability of code to inspect metadata and types in a compiled assembly at runtime. It lets a program discover methods, properties, attributes and fields, and sometimes create instances or invoke members dynamically.
How .NET Assembly Reflection Works
.NET assembly reflection is runtime metadata inspection. A loaded assembly exposes information about its types, members, attributes, interfaces, and signatures, so code can reason about what exists without hard-coding every type in advance. That makes reflection useful for plug-in models, dependency injection, serialization, testing, and extensibility patterns.
The key idea is that reflection reads what the compiler already emitted into the assembly, rather than scanning source code. In practice, that means a program can discover shape and capabilities dynamically, then decide whether to instantiate a type, call a method, or inspect annotations that affect behaviour.
Why Reflection Is Powerful in .NET
Reflection gives .NET applications flexibility that static code alone cannot provide. It supports late binding, where the exact type or member may not be known until execution time, and it enables generic tooling such as diagnostics, object mappers, and test frameworks that need to inspect arbitrary assemblies.
That same flexibility is why reflection is often associated with framework plumbing. Libraries can discover handlers, scan for attributes, or build object graphs at runtime, which reduces repetitive wiring and supports conventions over configuration.
Used carefully, reflection can improve maintainability by centralising discovery logic. Used broadly, it can also make code harder to follow, because control flow becomes less explicit and type errors may shift from compile time to runtime.
Security and Abuse Considerations
Reflection is not a vulnerability by itself, but it can increase attack surface when applications use untrusted input to select types, methods, or constructors. If dynamic lookup is poorly constrained, an attacker may steer execution toward unexpected code paths, abusive object creation, or sensitive members that were never meant to be reachable in normal application flow.
It also becomes more dangerous when reflection is combined with plugins, deserialisation, or loosely validated configuration. In those cases, the security question is not simply whether the assembly can be inspected, but whether runtime discovery is restricted to trusted assemblies and approved members.
Safe Use of Reflection in Application Design
The safest reflection patterns are narrow and intentional. Prefer explicit allowlists of assemblies, namespaces, types, and members; avoid using reflection to execute names supplied directly by users; and treat reflected calls as privileged operations that deserve the same review as other dynamic execution paths.
It is also important to separate reflection for inspection from reflection for invocation. Reading metadata is usually lower risk than dynamically creating objects or invoking methods, because execution introduces the possibility of side effects, privilege misuse, and unexpected dependency loading.
NIST Privacy Framework can help teams think clearly about data handling and component governance when reflective code touches sensitive application state, while NIST Cybersecurity Framework 2.0 provides a broader structure for governing the discovery, protection, and monitoring of dynamic runtime behaviours.
What to Watch for in Reviews and Debugging
Reflection deserves extra attention when code starts using string-based type names, wildcard scanning, or broad assembly loading. Those patterns often indicate that the application is making runtime decisions based on data that may not have been tightly validated at design time.
In reviews, the most useful question is whether the reflective operation is bounded. Good design keeps runtime discovery predictable, traceable, and limited to a known trust boundary, so reflection remains a convenience rather than an uncontrolled execution mechanism.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST CSF 2.0, CIS Controls v8 and OWASP ASVS set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | GV.PO-01 — Policy | Reflection needs governance over approved runtime discovery patterns. |
| PR.AA-05 — Least Privilege | Reflective execution should be constrained to the minimum set of trusted members. | |
| DE.CM-01 — Monitoring for Anomalies and Events | Unexpected reflective execution is a runtime behaviour worth monitoring. | |
| Recommendation — Define policy for permitted reflective loading and invocation patterns. Restrict reflective access to only trusted assemblies and members. Monitor for unusual dynamic type loading and invocation patterns. | ||
| CIS Controls v8 | CIS-6 — Access Control Management | Dynamic member access benefits from explicit access restrictions. |
| Recommendation — Limit reflective access paths to approved code and runtime contexts. | ||
| OWASP ASVS | V15 — Secure Coding and Architecture | Reflection is an architectural choice that can weaken code transparency if misused. |
| Recommendation — Review reflective code paths as part of secure architecture design. | ||
Related resources from NHI Mgmt Group
- What are the signs that a .NET framework is resolving assembly names from user-controlled request data?
- Reflective .NET Assembly Injection
- What breaks when authentication reflection is possible on a privileged Windows admin portal?
- How should security teams choose authentication for a .NET application that may need enterprise customers later?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 2, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org