Newest Viewed Downloaded

Cross Site Scripting Prof. Stefano BistarelliC Consiglio Nazionale delle Ricerche Iit Istituto di Informatica e Telematica - Pisa Università “G. d’Annunzio” Dipartimento di Scienze, Pescara

Cross Site Scripting Prof. Stefano Bistarelli

C Consiglio Nazionale delle Ricerche Iit Istituto di Informatica e Telematica - Pisa Università “G. d’Annunzio” Dipartimento di Scienze, Pescara

Cos'è il CSS?

Qualsiasi pagina Web che esegue il rendering HTML e contenente input dell'utente è vulnerabile Una tecnica che consente agli hacker di: Eseguire script dannoso nel browser Web di un client Inserire tag HTTP/1.0 Host: www.my-banca.it ... La risposta del sito vulnerabile sarà la seguente (interpretata sul browser dell’utente ignaro): Welcome! Hi
Welcome to our system ... The victim client’s browser would interpret this response as an HTML page containing a piece of 1. http://www.vulnerable.site/welcome.cgi?name= The victim, upon clicking the link, will generate a request to www.vulnerable.site, as follows: 2. Javascript code. This code, when executed, is allowed to access all cookies belonging to www.vulnerable.site, and therefore, it will pop-up a window at the client browser showing all client cookies belonging to www.vulnerable.site.

A.4: Cross-Site-Scripting (3)

Redirezione del contenuto del cookie dell’utente ignaro verso il server dell’attaccante Il malicious link può essere: http://www.my-banca.it/welcome.cgi?name= La risposta del server sarà: Welcome! Hi
Welcome to our system ... 1. Of course, a real attack would consist of sending these cookies to the attacker. For this, the attacker may erect a web site (www.attacker.site), and use a script to receive the cookies. Instead of popping up a window, the attacker would write a code that accesses a URL at his/her own site (www.attacker.site), invoking the cookie reception script with a parameter being the stolen cookies. This way, the attacker can get the cookies from the www.attacker.site server. 2. The browser, immediately upon loading this page, would execute the embedded Javascript and would send a request to the collect.cgi script in www.attacker.site, with the value of the cookies of www.vulnerable.site that the browser already has. This compromises the cookies of www.vulnerable.site that the client has. It allows the attacker to impersonate the victim. The privacy of the client is completely breached. The browser, immediately upon loading this page, would execute the embedded Javascript and would send a request to the collect.cgi script in www.attacker.site, with the value of the cookies of www.vulnerable.site that the browser already has. This compromises the cookies of www.vulnerable.site that the client has. It allows the attacker to impersonate the victim. The privacy of the client is completely breached.

Due impieghi comuni del CSS

Attaccare le piattaforme di posta elettronica basate sul Web e i forum Utilizzo dei tag
HTML per reindirizzare informazioni private

Attacchi basati su form (1 di 2)

Response.Write("Welcome" & Request.QueryString("UserName"))

Site soggetti a XSS/CSS

Vediamo l’esempio http://localhost/CrossScripting/Login.aspx

Proviamo..

Iniettiamo codice e vediamo che succede … Script eseguito sul mio browser … Ma come faccio io attaccante che non sono su macchina del client .. a prendermi il cookie?? …cerco il campo di input … txtname

E se chiamo la pagina cosi’? http://localhost/CrossScripting/Login.aspx?txtname= Funziona lo stesso!! Quindi se mando link a Maria e lei clicca esegue sul suo browser (credendo di andare al suo sito) il mio script!!

Attacchi basati su form (1 di 2)

Response.Write("Welcome" & Request.QueryString("UserName"))

… Ma come faccio io attaccante ad avere le info sul mio sito e non sullo schermo di Maria??

In generale …

Se ho input di questo tipo: http://victim.com/search.php ? term = apple search.php responds with: Search Results Results for : . . .

Posso usarlo cosi!!

http://victim.com/search.php ? term = Se la mia vittima clicca su questo link? Browser va a victim.com/search.php Victim.com restituisce Results for Browser executes script: Sends badguy.com cookie for victim.com

So what?

Perche’ un utente dovrebbe cliccare su quel link? Phishing email in webmail client (e.g. gmail). Link in doubleclick banner ad … many many ways to fool user into clicking Vedi esempio mail poste.it!! Cosa ci fa badguy.com con il cookie di victim.com ? Puo’ essere usato per spacciarsi per quell’utente per esempio!! (vedi lezione su cookies!!) http://rh731882.aspadmin.net/~scizza/bancoposta.online.it/bpol/cartepr/index.htm

Even worse

Attacker can execute arbitrary scripts in browser Can manipulate any DOM component on victim.com Control links on page Control form fields (e.g. password field) on this page and linked pages. Can infect other users: MySpace.com worm.

Difesa …

Avoiding XSS bugs (PHP)

Main problem: Input checking is difficult --- many ways to inject scripts into HTML. Preprocess input from user before echoing it PHP: htmlspecialchars(string) &  & "  " '  ' <  < >  > htmlspecialchars( "Test", ENT_QUOTES); Outputs: <a href='test'>Test</a>

Showing 1 - 20 of 31 items Details

Name: 
XSS
Author: 
N/A
Company: 
N/A
Description: 
Cross Site Scripting Prof. Stefano BistarelliC Consiglio Nazionale delle Ricerche Iit Istituto di Informatica e Telematica - Pisa Università “G. d’Annunzio” Dipartimento di Scienze, Pescara
Tags: 
script | cookie | document | input | http | html | your | welcome
Created: 
10/19/2007 12:07:36 AM
Slides: 
31
Views: 
14
Downloads: 
2
Rating: 
0


> Comment



Share this presentation
|

Comments

Share this presentation:

|
Sitemap