-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anouncement: Security with IsolatedRazorEngineService
#585
Comments
Here is some more technical detail about the vulnerability. It is possible to escape the AppDomain sandbox created by the IsolatedRazorEngine by creating a RazorDynamicObject which contains an expression. When this expression is compiled, the Compile() method is called in the security context of RazorEngine (Full-trust) and with a unrestricted security permission on the stack. .NET generates an anonymous assembly with this security information on the stack. When the resulting delegate is called it is possible to call any .NET code without the restriction of the sandbox (which leads to RCE). |
Are there any plans to release a stable package with a fix? Ref https://security.snyk.io/vuln/SNYK-DOTNET-RAZORENGINE-2419026 |
The vulnerability issue is for IsolatedRazorEngine only or it is for RazorEngineService as well. |
With RazorEngine itself you can already execute any template with any code. The vulnerability is related to the AppDomain isolation |
This issue is to inform everyone that
IsolatedRazorEngineService
, which uses CAS internally, should not be considered 'secure' anymore for various reasons:In addition to the above the following code sample was reported to me as an issue of RazorEngine itself (thanks @g2udevelopment):
If you depend on
IsolatedRazorEngineService
for security I'd urge you to redesign your security. If you need a fast fix, you can use the attached patch (0001-Not-so-Safe.zip) and compile RazorEngine yourself (however, you will not longer be able to use 'dynamic' with this patch).Just to clarify, you are only affected by this IF:
IsolatedRazorEngineService
and use CAS to control the template permissionsIf you use RazorEngine for E-Mail generation or templating Engine (documentation generation, ...) you are most likely not directly affected by this issue, even if you use
IsolatedRazorEngineService
as long as you use RazorEngine 'correctly'. Correct usage meansthat you don't allow direct user input to parts of the template. This mistake can happen if you use for example by string concatenation instead of using
@
Syntax-Elements. Just to remind you: If you use string concatenation to build your template with untrusted user inputs, you allow your users to execute code on your system. This is most likely not what you want with or without Isolation!The text was updated successfully, but these errors were encountered: