Update: You may also want to look at: Aggiornamento: Si potrebbe anche voler guardare: MySpace Hack: How To View Any Users Private Videos Incisione di MySpace: come visualizzare tutti gli utenti privati video .

Recently Recentemente Samy [samy at namb dot la] released a worm ["Samy worm" or "JS.Spacehero worm"] in MySpace, popular social networking platform like Friendster, which caused him to be added as hero to millions of MySpace users (”but most of all, samy is my hero.”) as well as add him as their friend, all without their explicit permission. [samy a punto la namb] rilasciato un worm [ "Samy worm" o "JS.Spacehero worm"] in MySpace, il popolare piattaforma di social networking come Friendster, che ha causato lui ad essere aggiunto come eroe a milioni di utenti di MySpace ( "ma la maggior parte di tutti i Samy è il mio eroe. "), come anche lui come aggiungere il loro amico, tutti senza il loro esplicito consenso.

After flooding the Network, MySpace stepped in and fixed the hole. Dopo le inondazioni di rete, MySpace è intervenuta e ha fissato il buco. Samy is still “hero” to millions of MySpace users in their profile. Samy è ancora "eroe" a milioni di utenti di MySpace nel loro profilo.

The purpose of this article is to highlight the security issues exposed by this worm. Lo scopo di questo articolo è quello di evidenziare il questioni di sicurezza esposti da questo worm. It is definitely not limited to MySpace alone and the worm propagated not due to MySpace’s fault but fault of browser like Internet Explorer. Non è certamente limitato a MySpace da solo e il worm propagati non a causa di MySpace colpa ma per colpa del browser come Internet Explorer. And the flaw is waiting to be exploited in several other web applications of similar nature like Ryze or LinkedIn etc.. E il difetto è in attesa di essere sfruttati in diverse altre applicazioni web di natura analoga, come Ryze o LinkedIn ecc. In the remainder of this article I will summarize the modus-operandi of his script and suggest on ways to protect your web application against such attacks. Nel resto di questo articolo vorrei riassumere il modus-operandi del suo script e suggerire sui modi per proteggere la vostra applicazione web contro tali attacchi.

Samy used AJAX to add himself as a friend and hero when users visited his page. Samy AJAX utilizzato per aggiungere se stesso come un amico e un eroe quando gli utenti hanno visitato la sua pagina. This requires Javascript to be executed in the browser which does the dirty work. Questo richiede l'uso di Javascript per essere eseguiti nel browser che fa il lavoro sporco.

MySpace dutifully eliminates javascript from users html (which becomes their profile). MySpace lealtà elimina javascript html da parte degli utenti (che diventa il loro profilo). However Sammy disguised the word javascript with an embedded newline - “java\nscript”. Tuttavia Sammy dissimulata la parola javascript incorporato con un newline - "java \ nscript".

MySpace doesn’t allow script tags. MySpace non consente tag di script. So he embedded his javascript in CSS - style=”background:url(’javascript:eval(document.all.mycode.expr)’)” Così ha incorporato la sua JavaScript nel CSS - style = "background: url ( 'javascript: eval (document.all.mycode.expr)')"

AJAX can fetch documents from the same domain (or sub-domain) only. AJAX può scaricare i documenti provenienti dallo stesso dominio (o sub-dominio). So if the user was on profile.myspace.com, he moved them to www.myspace.com which provides the same information but allows him to be added as a friend. Quindi, se l'utente è stato a profile.myspace.com, si trasferì a www.myspace.com che fornisce le stesse informazioni, ma gli permette di essere aggiunto come un amico.
if (location.hostname == 'profile.myspace.com') document.location = 'http://www.myspace.com' + location.pathname + location.search; if (location.hostname == 'profile.myspace.com') document.location = 'http://www.myspace.com' location.pathname + + location.search;

After overcoming a trvial hash issue he adds his code and “but most of all, samy is my hero.” text to users profile. Dopo aver superato uno trvial hash questione, aggiunge il suo codice e "ma la maggior parte di tutti, samy è il mio eroe." Testo per gli utenti profilo. This causes the worm to propagate not only when users visit his site but also when they visit any of the infected users. Questo fa sì che il worm per propagarsi non solo quando gli utenti visitano il suo sito, ma anche quando visitano uno qualsiasi degli utenti infettati. Yes, simple exponential spreading. Sì, semplice diffusione esponenziale.

Samy provides Samy fornisce detailed notes and code for his exploit note dettagliate e il codice per il suo exploit after the exploit was filtered / stopped by MySpace. dopo l'exploit è stato filtrato / smesso di MySpace.

How can you protect your web application from such attacks? Come si può proteggere l'applicazione web da tali attacchi?
First and foremost I assume you have filtering in place like MySpace did filtering scripts and javascript tags etc. However obviously that is not enough; not even close. In primo luogo ritengo che avete di filtraggio in atto, come ha fatto il filtraggio MySpace script e tag JavaScript ecc Tuttavia, ovviamente, che non è sufficiente, neppure vicino.
Your filtering tags should be intelligent to recognize words separated by newlines as shown above. I filtri tag deve essere intelligente per il riconoscimento delle parole separate da capo, come indicato sopra.

Other users profile (or any html content) should be viewable only from a separate sub-domain. Profilo di altri utenti (o qualsiasi contenuto HTML) dovrebbe essere visibile solo da una sotto-dominio.

Any actions like adding a link, friend, connection etc. must be done from pages which can never contains any other users code. Eventuali azioni come l'aggiunta di un link, amico, ecc connessione deve essere fatto dalle pagine che non può mai contenente gli altri utenti codice. If you provide a link while viewing others profile to add his as a friend then on clicking you take him to a separate page where the users gets to edit information about his friend and add him after confirmation. Se si fornire un collegamento durante la visualizzazione di altri profilo di aggiungere il suo come un amico cliccando poi su di lui si prende a una pagina separata in cui gli utenti viene a modificare le informazioni circa il suo amico e aggiungere lui dopo la conferma. This page should not contain any html content from the user being added. Questa pagina non deve contenere qualsiasi contenuto HTML, da parte degli utenti che viene aggiunto.

In essence we need to captalize on AJAX security model which prevents code execution from different site. In sostanza dobbiamo captalize su AJAX modello di sicurezza che impedisce l'esecuzione di codice da diversi sito.