Json xss prevention

Source: Internet
Author: User

WoYiGuis BLoG

It seems that most people are not too popular with json xss recently, Google once: http://ha.ckers.org/blog/20060704/cross-site-scripting-vulnerability-in-google/
It seems that you already know this.

Therefore, it is easy to prevent such XSS attacks. For example, the pages with XSS vulnerabilities are as follows:

<? PHP
$ Woyigui = $ _ GET ["xss"];
Echo $ woyigui;
?>

Of course, the specific application is more complex, and the patching method is very simple. developers can change it to the following:

<? PHP
Header ("Content-type: application/json ");
$ Woyigui = $ _ GET ["xss"];
Echo $ woyigui;
?>

Modify the MIME document type. During the test, we found that text/plain and application/x-zip-compressed will be parsed by IE. There should be others, but none of them were tested one by one.

More documents:
Http://www.rfc-editor.org/rfc/rfc4627.txt
Html> http://www.dev411.com/blog/2006/07/24/json-xss-exploit-dont-use-text-html
Http://ha.ckers.org/blog/20060704/cross-site-scripting-vulnerability-in-google/
Http://www.souzz.net/html/Security/3/38128.html

Http://hi.baidu.com/momoca/blog/item/91317bf451b322d9f2d385f8.html Content-type table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.