简体   繁体   English

xss有效负载未在浏览器中执行

[英]xss payload not executing in browser

I am doing penetration testing for a .net MVC application. 我正在为.net MVC应用程序进行渗透测试。 The application uses Javascript frameworks/libraries like Jquery and angular JS. 该应用程序使用Javascript框架/库,例如Jquery和angular JS。

There is an input field on the web page where I'm able to insert <script>alert(1)</script>. 网页上有一个输入字段,我可以在其中输入<script>alert(1)</script>. The web application sends the input back through AJAX response (json response). Web应用程序通过AJAX响应(json响应)将输入发送回。 I can find my input reflected as it is on the web page but the javascript payload that I have given to test XSS does not execute. 我可以在网页上反映出我的输入,但是我提供的用于测试XSS的javascript有效负载无法执行。 I've tested it in google chrome and IE. 我已经在谷歌浏览器和IE中对其进行了测试。

I've checked the AJAX response and there is no output encoding present. 我已经检查了AJAX响应,并且没有输出编码。

Although the header X-XSS-Protection:1; 尽管标题X-XSS-Protection:1; mode=block is present, I don't see any error in Google chrome console regarding blocking of unsafe script (we usually get this error if chrome blocks execution of unsafe javascript). mode = block存在,我看不到Google chrome控制台中有关阻止不安全脚本的任何错误(如果chrome阻止执行不安全的javascript,我们通常会收到此错误)。

I checked the following url to see if angual-js does output encoding/escaping by-default. 我检查了以下网址,以了解angual-js是否默认输出编码/转义。 https://docs.angularjs.org/guide/security but don't get it fully. https://docs.angularjs.org/guide/security,但请不要完全了解。

When I inspect the element ie my input( <script>alert(1)</script> ), I get the following thing: 当我检查元素即输入( <script>alert(1)</script> )时,得到以下内容:

<textarea rows="3" ng-model="abc" maxlength="500" placeholder="xyz" ng-readonly="abcd>1" input-restrictor="" class="ng-pristine ng-valid ng-valid-maxlength ng-not-empty ng-touched" aria-multiline="true" aria-invalid="false" readonly="readonly"></textarea>

Any insight why my JS payload is not executing in the browser? 有什么见解为什么我的JS有效负载未在浏览器中执行?

Finally I got the answer. 终于我得到了答案。 AngularJS does output encoding before rendering the content. AngularJS在呈现内容之前不会输出编码。 our payload - 我们的有效载荷-

<script>alert('xss')</script>

becomes something like this as shown in image. 变成如图所示的样子。 Browser treats it as plain text instead of javascript and hence it does not execute. 浏览器将其视为纯文本而不是javascript,因此不会执行。

You can see the output encoding only when you inspect the element and do right click and edit as HTML. 仅当您检查元素并右键单击并编辑为HTML时,才能看到输出编码。 I have also written a more detailed blog post here https://medium.com/@nav7neeet/angular-js-and-xss-458eea91f3a5 我还在这里https://medium.com/@nav7neeet/angular-js-and-xss-458eea91f3a5撰写了更详细的博客文章

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM