XSS in angularjs app and web api 2 -
i have web application. using angularjs , web api2.
i have simple form user can insert free text send via email other people. text saved on db , later can shown in web site page. knew didn't need check input of user, because in web api, text automatically encoded. expected if user, example, type
<script type="..">...</script> i receive server side, in web api controller, this:
<script type="..">...</script> i receive instead
<script type="..">...</script> nothing changed.
how can encode input sure application not receive xss attack? should leave input unchanged change value when put in email? , when save in database? should saved in form
<script type="..">...</script> and encoded when show in page?
in moment added in web.config
<httpruntime ... encodertype="system.web.security.antixss.antixssencoder,system.web, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" /> but nothing seems changed.
thank you
you have multiple possibilities, can encode string data received (https://github.com/mathiasbynens/he) before saving them db, in manner don't need nothing displaying them, because displayed string <script type="..">...</script> example.
but if still want accept html tags <p>, <strong>, etc... should save input without encoding , using sanitizer display them: https://docs.angularjs.org/api/ng/directive/ngbindhtml
Comments
Post a Comment