Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a risk in using @Html.Raw?

Is there a risk in using @Html.Raw? It seems to me there shouldn't be. If there is a risk then wouldn't that risk already exist regardless of using @Html.Raw in that modern browsers such as Chrome will allow an edit injection of <script>malicious()</script> or even to change a form's post action to something else.

like image 504
Travis J Avatar asked Jun 21 '12 18:06

Travis J


2 Answers

@Html.Raw will allow executing any script that is on the value to display. If you want to prevent that you need to use @Html.AttributeEncode

like image 124
pollirrata Avatar answered Oct 07 '22 06:10

pollirrata


Correct, the risk is in how it is used. There's no risk inherent in Html.Raw. It's a tool, nothing more.

like image 40
neontapir Avatar answered Oct 07 '22 06:10

neontapir