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:

&lt;script type=&quot;..&quot;&gt;...&lt;/script&gt; 

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 &lt;script type=&quot;..&quot;&gt;...&lt;/script&gt; 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

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -