CVE-2021-46703
Description
In the IsolatedRazorEngine component of Antaris RazorEngine through 4.5.1-alpha001, an attacker can execute arbitrary .NET code in a sandboxed environment (if users can externally control template contents). NOTE: This vulnerability only affects products that are no longer supported by the maintainer
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Antaris RazorEngine's IsolatedRazorEngineService allows arbitrary .NET code execution via crafted templates, affecting unsupported versions through 4.5.1-alpha001.
Vulnerability
The IsolatedRazorEngineService component of Antaris RazorEngine through version 4.5.1-alpha001 uses Code Access Security (CAS) to sandbox template execution. CAS has been deprecated and is no longer supported on modern .NET platforms, making the sandbox ineffective. An attacker who can control template content can bypass the sandbox and execute arbitrary .NET code [1][3].
Exploitation
An attacker needs the ability to supply or influence template content (e.g., through user input or external data). The attacker crafts a Razor template that leverages System.IO, RazorEngine.Compilation.RazorDynamicObject, and expression trees to compile and invoke arbitrary actions. For example, the template can write a file to disk by constructing a lambda expression and calling Compile() on a dynamic object [3]. No authentication or special privileges are required if the template input is exposed.
Impact
Successful exploitation allows the attacker to execute arbitrary .NET code within the application's security context. This can lead to full compromise of the host system, including file write, data exfiltration, or further lateral movement. The sandbox is completely bypassed [3].
Mitigation
No official fix exists; the product is end-of-life and no longer supported by the maintainer. A community-provided patch (attached to issue #585) disables dynamic support but is not an official release. Users are strongly advised to stop using IsolatedRazorEngineService for security purposes and redesign their architecture to avoid relying on CAS-based sandboxing [1][3].
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
RazorEngineNuGet | <= 4.5.1-alpha001 | — |
Affected products
3- Antaris RazorEngine/Antaris RazorEnginedescription
- Range: <=4.5.1-alpha001
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
3- github.com/advisories/GHSA-ph3v-2hq5-5qfqghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2021-46703ghsaADVISORY
- github.com/Antaris/RazorEngine/issues/585ghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.