User:Ilafmi/sandbox

From Wikipedia, the free encyclopedia

Classificazione dei vettori di attacchi SQL injection nel 2010
Classificazione dei vettori di attacchi SQL injection nel 2010

SQL injection è una tecnica di code injection, usata per attaccare applicazioni data-driven, con la quale vengono inseriti degli statement SQL malevoli all’interno di campi di input in modo che vengano eseguiti (es. per fare inviare il contenuto del database all’attaccante).[1] L’SQL injection sfrutta le vulnerabilità di sicurezza del software di un’applicazione, ad esempio, quando l’input dell’utente non è correttamente filtrato da string literal escape characters contenuti negli statement SQL oppure non è fortemente tipizzato e viene eseguito inaspettatamente. L’SQL injection è più conosciuto come attacco per i siti web, ma è anche usato per attaccare qualsiasi tipo di database SQL.

L’SQL injection permette agli attaccanti di effettuare spoof identify, modificare dati esistenti, causare repudiation issues come l’annullamento di transazioni o la modifica dei bilanci, permette di ottenere tutti i dati sul sistema, eliminare dati oppure fare in modo che non siano accessibili, e diventare amministratori del database server.

In uno studio del 2012, è stato osservato che in media le applicazioni web ricevono 4 attacchi al mese, ed i rivenditori ricevono il doppio degli attacchi rispetto alle industrie. [2]

Storia[edit]

Le prime discussioni pubbliche relative all'SQL injection sono apparse attorno al 1998. [3] Per esempio, un articolo del 1998 su Phrack Magazine.[4]

Tipi di SQL injection[edit]

L’SQL injection (SQLI) è considerata da Open Web Application Security Project una delle 10 maggiori vulnerabilità delle applicazioni web nel 2007 e nel 2010. [5] Nel 2013 SQLI è stato considerato il numero uno degli attacchi sulla OWASP top 10.[6] Ci sono quattro principali sotto classi di SQL injection:

Lo Storm Worm è un esempio di utilizzo delle Compounded SQLI.[11]

Questa classificazione lo stato dell’SQLI rappresenta la sua evoluzione fino al 2010.[12]

Implementazioni tecniche[edit]

Caratteri di escape non filtrati correttamente[edit]

Questo tipo di SQL injection si verifica quando non viene filtrato l’input dell’utente dai caratteri di escape e quindi vengono passati all'interno di uno statement. Questo può provocare la manipolazione degli statements eseguiti sul database dagli utenti finali dell’applicazione.

La seguente linea di codice illustra questo tipo di vulnerabilità:

statement = "SELECT * FROM users WHERE name = '" + userName + "';"

Questo codice SQL recupera tutti i record che hanno un certo username dalla tabella users. Tuttavia, se un utente malintenzionato scrive la variabile “userName” in un certo modo, lo statement SQL può fare più di quello che era inteso dall'autore del codice. Per esempio, impostando la variabile “userName” come:

' OR '1'='1

Oppure usando dei commenti per non fare eseguire il resto della (ci sono tre tipi di commenti SQL [13]). Tutti e tre le linee hanno uno spazio alla fine:

' OR '1'='1' --
' OR '1'='1' ({
' OR '1'='1' /* 

Ecco come appare il rendering dello statement SQL dopo l’inserimento di una delle linee di codice con commento e senza:

SELECT * FROM users WHERE name = '' OR '1'='1';
SELECT * FROM users WHERE name = '' OR '1'='1' -- ';

Se questo codice fosse utilizzato in una procedura di autenticazione, allora questo esempio potrebbe essere usato per forzare la selezione di tutti i campi dati (*) da “tutti” gli utenti piuttosto che da un singolo username come era inteso dal codice, ciò accade perché la valutazione di ‘1’=’1’ è sempre (short-circuit evaluation).

Nell’esempio di sotto il valore di “userName” causerebbe l’eliminazione della tabella “user” e la selezione di tutti i dati nella tabella “userinfo” (in pratica rivelando le informazioni di tutti gli utenti), usando un API che permette statement multipli:

a'; DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't

L’inserimento dell’input specificato sopra fa diventare lo statement SQL in questo modo:

SELECT * FROM users WHERE name = 'a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't';

Mentre molte delle implementazioni degli SQL server permettono di eseguire statement multipli con un’unica chiamata, alcune di queste API come nella funzione mysql_query() di PHP non lo permettono per motivi di sicurezza. Questo evita che gli attaccanti iniettino delle query completamente separate all'interno dello statement, ma ciò non li ferma dal modificarle.

Gestione non corretta del tipo[edit]

Questo tipo di SQL injection si verifica quando un campo fornito dall'utente non è fortemente tipizzato o non vengono controllati i vincoli sul tipo. Questo può accadere, ad esempio, quando viene utilizzato un campo numerico in uno statement SQL, ma il programmatore non fa controlli per verificare che l’input immesso dall'utente sia effettivamente numerico. Per esempio:

statement := "SELECT * FROM userinfo WHERE id =" + a_variable + ";"

Da questo statement è evidente che l’autore voleva che la variabile fosse un numero riferito al campo "id". Tutta via se essa è di fatto una stringa, allora l’utente finale potrebbe manipolare lo statement a suo piacimento, e quindi aggirare la necessità di caratteri di escape. Per esempio, impostando una variabile a

1;DROP TABLE users

Viene fatto il drop (eliminazione) della tabella "users" dal database, visto che lo statement SQL diventa:

SELECT * FROM userinfo WHERE id=1; DROP TABLE users;

Blind SQL injection[edit]

Il Blind SQL Injection è usato quando un’applicazione web è vulnerabile ad SQLI ma i risultati dell’operazione non sono visibili all'attaccante. La pagina con la vulnerabilità potrebbe non essere una che mostra dei dati, ma può essere visualizzata differentemente a seconda del risultato dello statement di tipo logico iniettato dentro lo statement SQL originale, chiamato per quella pagina. Questo tipo di attacco può impiegare un notevole dispendio di tempo perché devo creare un nuovo statement per ogni bit recuperato. Ci sono vari strumenti che permettono di automatizzare questi attacchi una volta che sono stati individuati dov'è la vulnerabilità e qual è l’informazione obiettivo.[14]

Risposte condizionali[edit]

Uno dei tipi di blind SQL injection forza il database a valutare uno statement logico su un’ordinaria schermata dell’applicazione. Ad esempio, un sito di recensioni sui libri usa una query string per decidere che recensione su quale libro mostrare. Quindi l’URL http://books.example.com/showReview.php?ID=5 farà eseguire al server la query

SELECT * FROM bookreviews WHERE ID = 'Value(ID)';

Con la quale popolerà la pagina con i dati della recensione con ID 5, memorizzati nella tabella bookreviwes. La query viene eseguita completamente sul server; quindi l’utente non saprà i nomi del database, della tabella, o dei campi, e nemmeno conoscerà la query string. L’utente vedrà soltanto che l’URL di sopra ritorna la recensione di un libro. Un Hacker può caricare i seguenti URL http://books.example.com/showReview.php?ID=5 OR 1=1 e http://books.example.com/showReview.php?ID=5 AND 1=2, che potrebbero generare rispettivamente l’esecuzione di queste query:

SELECT * FROM bookreviews WHERE ID = '5' OR '1'='1';
SELECT * FROM bookreviews WHERE ID = '5' AND '1'='2';

Se utilizzando l'URL con "1=1" viene caricata la recensione originale e con l'URL che ha "1=2" viene caricata una pagina bianca o d’errore, e la pagina ritornata non mostra all’utente che è appena stato inserito un URL non valido, è molto probabile che il sito sia vulnerabile ad attacchi di SQL injection perché vuol dire che entrambe le query potrebbero essere state eseguite correttamente dal database server. L’hacker potrebbe eseguire la seguente query string per venire a conoscenza del numero di versione di MySQL presente sul server: http://books.example.com/showReview.php?ID=5 AND substring(@@version, 1, INSTR(@@version, '.') - 1)=4, una volta eseguita mostrerebbe la recensione del libro se il server utilizza MySQL 4 ed altrimenti una pagina bianca o d’errore. L’hacker può continuare ad usare del codice all'interno delle query string per ottenere sempre più informazioni sul server fino a quando non viene scoperta una nuova via di attacco oppure fino a quando i suoi obiettivi non siano raggiunti.[15][16]

Second order SQL injection[edit]

Il Second order SQL injection si verifica quando i valori inviati dalllutente contengono comandi maligni che vengono salvati sul server piuttosto che vengano eseguiti immediatamente. In alcuni casi, l’applicazione può memorizzare l’input maligno come se fosse uno statement SQL valido, ed un’altra parte dell’applicazione che non effettua controlli per proteggersi da SQL injections potrebbe eseguire lo statement memorizzato. Questo tipo di attacco richiede la conoscenza che i valori inviati vengano utilizzati successivamente. Gli scanner di sicurezza per applicazioni web potrebbero non accorgersi facilmente questo tipo di SQL injection e potrebbero aver bisogno di essere istruite manualmente su dove cercare indizi sull'attacco.

Prevenzione[edit]

L’ SQL injection è un attacco molto conosciuto e facilmente evitabile con semplici misure. Dopo quello che si pensa fosse stato un attacco di SQL injection su Talktalk, la BBC ha riportato come gli esperti di sicurezza fossero stupiti che una così grande compagnia fosse vulnerabile a questo tipo di attacco. [17]

Statements parametrizzati[edit]

Con molte delle piattaforme di sviluppo, è possibile usare statement parametrizzati che lavorano con dei parametri (chiamati placeholder o bind variable) al posto di inserire direttamente l’input dell’utente direttamente nello statement. Un placeholder può memorizzare soltanto un valore del tipo specificato e non un qualsiasi statement SQL. In questo modo l'SQL injection viene trattata semplicemente come un valore non valido per quel parametro.

In molti casi, lo statement SQL viene invece fissato, ed ogni parametro è quindi uno scalare, e non una tabella. In many cases, the SQL statement is fixed, and each parameter is a scalar, not a table. L’input dell’utente è quindi assegnato (legato) ad un parametro. [18]

Rafforzamento a livello di codice[edit]

Usare delle librerie di object-relational mapping evita di scrivere codice SQL. Le librerie ORM generano automaticamente degli statement SQL parametrizzati, partendo da del codice orientato agli oggetti.

Escaping[edit]

Un modo diretto, anche se soggetto ad errori per prevenire attacchi di SQLI è quello di evitare caratteri che hanno un che hanno un significato speciale in SQL. I manuali dei DBMS SQL spiegano quali caratteri hanno significati speciali, ciò permette di creare una lista di caratteri che devono essere sostituiti perché potenzialmente dannosi. Ad esempio, ogni apostrofo (') in un parametro deve essere sostituito con le virgolette ('') per ottenere una stringa SQL di letterali valida. Per esempio, in PHP di solito si evitano i caratteri speciali nei parametri utilizzando la funzione mysqli_real_escape_string(); prima di inviare a query SQL:

$mysqli = new mysqli('hostname', 'db_username', 'db_password', 'db_name');
$query = sprintf("SELECT * FROM `Users` WHERE UserName='%s' AND Password='%s'",
                  $mysqli->real_escape_string($username),
                  $mysqli->real_escape_string($password));
$mysqli->query($query);

Questa funzione antepone dei backslash ai seguenti caratteri: \x00, \n, \r, \, ', " e \x1a. Essa è di solito usata per rendere sicure le query prima di inviare ad un database MySQL. [19]
In PHP vi sono tante altre funzioni per vari tipi di database come pg_escape_string() per PostgreSQL. La funzione addslashes(string $str) serve ad evitare i caratteri speciali, ed è usata in particolare per fare query a database che non hanno funzioni di escape in PHP, essa ritorna una stringa con dei backslash prima dei caratteri che hanno bisogno di essere tra apici. Questi caratteri sono l’apostrofo ('), doppi apici ("), il backslash ed il caratter NULL. [20]
Fare sempre l’escape delle stringhe SQL è soggetto ad errori perché è facile dimenticare di fare l’escape di una determinata stringa. Creare un livello trasparente per rendere sicuro l’input può ridurre gli errori o eliminarli totalmente. [21]

Controllo dei pattern[edit]

Si possono controllare parametri con stringhe di interi, float or booleani, e verificare se il loro valore ha una valida struttura per il tipo di dato controllato. Le stringhe che hanno una struttura abbastanza rigida (data, UUID, solo alfanumerici, ecc.) possono essere controllati per vedere se rispecchiano la struttura del tipo di dato.

Permessi del database[edit]

Limitare i permessi nel logon usato dell’applicazione web per accedere al database, mettendo solo i permessi necessari, può servire a ridurre l’efficacia di qualsiasi attacco SQL injection, mirato a dei bug dell’applicazione.

Per esempio, su Microsoft SQL Server, si può proibire al logon del database di fare una select ad alcune delle tabelle di sistema, in questa maniera viene evitato che venga inserito del Javascript all'nterno di tutte le colonne del database

deny select on sys.sysobjects to webdatabaselogon;
deny select on sys.objects to webdatabaselogon;
deny select on sys.tables to webdatabaselogon;
deny select on sys.views to webdatabaselogon;
deny select on sys.packages to webdatabaselogon;

Conversione esadecimale[edit]

La conversione esadecimale viene fatta convertendo del semplice testo nella sua rappresentazione esadecimale prima di usarle in un comando SQL. In PHP, le funzioni usate sono la funzione bin2hex()[22] o dechex[23]. La funzione bin2hex() è da preferire visto che converte qualsiasi carattere e non solo numeri. In questa sezione verrà usata solo la funzione bin2hex().

Esempio di utilizzo della funzione di PHP bin2hex():

echo bin2hex("test");

L’output della funzione sopra è:

74657374

A scopo d’esempio parliamo soltanto Del database MySQL[24]. In MySQL, la funzione unhex()[25] è usata per riconvertire una stringa esadecimale in semplice testo.

Esempio della funzione unhex() in MySQL:

SELECT * FROM myTable WHERE id=unhex('32');

Se convertissimo la stringa con unhex() in semplice testo diventerebbe:

SELECT * FROM myTable WHERE id=2;

La conversione esadecimale elimina gli attacchi di SQL injection perché la stringa esadecimale inviata alla funzione unhex() viene ritornata come stringa usata e non viene interpretata.

Esempio di programmazione[edit]

Nel seguente breve programma viene presentato un programma PHP con una funzione PHP. Il programma mostra un attacco di SQL injection su un semplice comando SQL. Successivamente, mostra come convertendo tutte i dati in entrata in esadecimale, riesca a fermare l’attacco. La funzione PHP è un semplice insieme di comandi per il database così come recupero dell’output dal database SQL. Come detto sopra il database usato è MySQL.

Codice d’esempio[edit]
File: test.php
<?php

    include_once "dosql.php";
#
#   Metti le informazioni sul tuo database qui.  Stò usando i dati del mio file di log.
#
    $hostname = "myhost";
    $username = "myUser";
    $password = "myPassword";
    $database = "myDatabase";

    $mysqli = new mysqli($hostname, $username, $password, $database);

    if ($mysqli->connect_errno) {
        echo "Failed to connect to MySQL: (", $mysqli->connect_errno, ") ", $mysqli->connect_error;
        exit;
    }
    echo "SQL INJECTION - Plain\n";
    $sql = "SELECT * FROM log WHERE log_id='2' OR 1=1; #'";
    $res = dosql($sql);
    foreach ($res[0] as $k => $v) {
        echo "RES[$k] = $v\n";
    }

    echo "\n\nSQL INJECTION = Hexadecimal\n";
    $sql = "SELECT * FROM log WHERE log_id=unhex('" . bin2hex("2' or 1=1; #'") . "')";
    $res = dosql($sql);
    foreach ($res[0] as $k => $v) {
        echo "RES[$k] = $v\n";
    }

    exit;
?>

File: dosql.php
<?php

################################################################################
#   dosql(). Do the SQL command.
################################################################################
function dosql($sql)
{
    global $mysqli;

    $cmd = "INSERT INTO log (date,entry) VALUES (NOW(), unhex('" . bin2hex($sql) . "'))";
    $res = $mysqli->query($cmd);

    $res = $mysqli->query($sql);
    if (!$res) {
        $array = debug_backtrace();
        if (isset($array[1])) { $a = $array[1]['line']; }
        else if (isset($array[0])) { $a = $array[0]['line']; }
        else { $a = "???"; }

        echo "ERROR @ ", $a, " : (", $mysqli->errno, ")\n", $mysqli->error, "\n\n";
        echo "SQL = $sql\n";
        exit;
    }

    if (preg_match("/INSERT/i", $sql)) { return $mysqli->insert_id; }
    if (preg_match("/DELETE/i", $sql)) { return null; }
    if (!is_object($res)) { return null; }

    $count = -1;
    $array = array();
    $res->data_seek(0);
    while ($row = $res->fetch_assoc()) {
        $count++;
        foreach ($row as $k => $v) { $array[$count][$k] = $v; }
    }

    return $array;
}
Output del programma[edit]
SQL INJECTION - Plain
RES[log_id] = 1
RES[date] = 2015-03-25 10:40:18
RES[entry] = SHOW full columns FROM log

SQL INJECTION = Hexadecimal
RES[log_id] = 2
RES[date] = 2015-03-25 10:40:18
RES[entry] = SELECT * FROM log ORDER BY title ASC

La prima parte dell’output del programma mostra l’invio del comando SQL senza fare controllo o modifiche. La richiesta originale dovrebbe far ritornare il secondo record, ma grazie all’SQL injection viene ritornato il primo record. La seconda parte dell’output mostra invece cosa succede se vengono convertiti tutti i dati in ingresso in esadecimale. Usando a conversione, tutti i caratteri nel comando, inclusi quelli inseriti dall’SQL injection, vengono convertiti in esadecimale e non sono più un pericolo perché non vengono interpretati come comandi ma come stringhe. Visto che tutti i caratteri vengono trattati come parte dell’intera stringa, se MySQL capisce che ha bisogno di un numero, converte la stringa in numero. Le regole per la conversione da stringa a numero, sono di convertire [26] la stringa fino a quando non raggiunge un carattere non numerico o la fine della stringa. Quando si verifica uno di questi due eventi, la conversione si arresta in quel punto. Quindi, viene visto il “2” e poi l’apostrofo (‘), il che dice a My SQL di terminare la conversione della stringa. Infine il valore numerico due(2) viene usato per determinare quale record ritornare. Questo processo o metodo di valutazione dei dati in ingresso è il motivo per cui non possono avvenire attacchi di SQL injection se si usa una conversione esadecimale.

Considerazioni aggiuntive[edit]

In aggiunta, l’utilizzo di BIN2HEX and UNHEX richiede meno tempo d’esecuzione rispetto agli altri metodi presentati. Questo accade principalmente per l nature semplicistica di entrambe le funzioni. Come mostrato nello snippet Javascript, convertire in esadecimale è piuttosto semplice e diretto:

Codice d’esempio[edit]
File: toHex.js
////////////////////////////////////////////////////////////////////////////////
//	toHex().  Converte una stringa in esadecimale.
////////////////////////////////////////////////////////////////////////////////
function toHex(s)
{
	var l = "0123456789ABCDEF";
	var o = "";

	if (typeof s != "string") { s = s.toString(); }
	for (var i = 0; i < s.length; i++) {
		var c = s.charCodeAt(i);
		o = o + l[(c >> 4)] + l[(c & 0xf)];
	}

	return o;
}

Come mstrato, a differenza di mysqli_real_escape_string()[27] con il quale deve essere fatto il test di escape per ogni differente, bin2hex() converte semplicemente tutti i caratteri nel loro corrispettivo esadecimale. E la funzione unhex()fa l’operazione opposta. Visto che non devono essere fatti test per un particolare carattere o caratteri, il ciclo di conversione è piccolo ed efficiente. Inoltre, a differenza di mysqli_real_escape_string(), se in futuro dovesse essere scoperto un nuovo metodo, la funzione bin2hex() disabiliterà automaticamente la combinazione di caratteri, perché ritorna una stringa esadecimale. Un esempio di questo è il carattere Control-D ASCII. [28] Control-D può provocare una condizione "Fine della trasmissione"[29] in alcuni linguaggi. Se viene usata la funzione bin2hex() il Control-D diventa semplicemente il semplice testo ASCII “04” che non può causare problemi.

Articoli[edit]

Ci sono diversi articoli su internet che parlano della Conversione esadecimale e come fermare gli attacchi di SQLI. Alcuni di questi sono:

  1. E’ sufficiente la conversione esadecimale per rendere sane le query SQL? [30]
  2. Utilizzo di bin2hex ed unhex come semplice metodo di prevenzione da sql injection [31]
  3. I migliori modi per prevenire l’SQL? [32]
  4. SQL Injections – La soluzione finale a[33]

Esempi[edit]

  • In February 2002, Jeremiah Jacks discovered that Guess.com was vulnerable to an SQL injection attack, permitting anyone able to construct a properly-crafted URL to pull down 200,000+ names, credit card numbers and expiration dates in the site's customer database.[34]
  • On November 1, 2005, a teenage hacker used SQL injection to break into the site of a Taiwanese information security magazine from the Tech Target group and steal customers' information.[35]
  • On January 13, 2006, Russian computer criminals broke into a Rhode Island government website and allegedly stole credit card data from individuals who have done business online with state agencies.[36]
  • On March 29, 2006, a hacker discovered an SQL injection flaw in an official Indian government's tourism site.[37]
  • On June 29, 2007, a computer criminal defaced the Microsoft UK website using SQL injection.[38][39] UK website The Register quoted a Microsoft spokesperson acknowledging the problem.
  • In January 2008, tens of thousands of PCs were infected by an automated SQL injection attack that exploited a vulnerability in application code that uses Microsoft SQL Server as the database store.[40]
  • In July 2008, Kaspersky's Malaysian site was hacked by a Turkish hacker going by the handle of "m0sted", who said to have used an SQL injection.
  • In February 2013, a group of Maldivian hackers, hacked the website " UN-Maldives" using SQL Injection.
  • In May 28, 2009 Anti-U.S. Hackers Infiltrate Army Servers Investigators believe the hackers used a technique called SQL injection to exploit a security vulnerability in Microsoft's SQL Server database to gain entry to the Web servers. "m0sted" is known to have carried out similar attacks on a number of other websites in the past—including against a site maintained by Internet security company Kaspersky Lab.
  • On April 13, 2008, the Sexual and Violent Offender Registry of Oklahoma shut down its website for "routine maintenance" after being informed that 10,597 Social Security numbers belonging to sex offenders had been downloaded via an SQL injection attack[41]
  • In May 2008, a server farm inside China used automated queries to Google's search engine to identify SQL server websites which were vulnerable to the attack of an automated SQL injection tool.[40][42]
  • In 2008, at least April through August, a sweep of attacks began exploiting the SQL injection vulnerabilities of Microsoft's IIS web server and SQL Server database server. The attack does not require guessing the name of a table or column, and corrupts all text columns in all tables in a single request.[43] A HTML string that references a malware JavaScript file is appended to each value. When that database value is later displayed to a website visitor, the script attempts several approaches at gaining control over a visitor's system. The number of exploited web pages is estimated at 500,000.[44]
  • On August 17, 2009, the United States Department of Justice charged an American citizen, Albert Gonzalez, and two unnamed Russians with the theft of 130 million credit card numbers using an SQL injection attack. In reportedly "the biggest case of identity theft in American history", the man stole cards from a number of corporate victims after researching their payment processing systems. Among the companies hit were credit card processor Heartland Payment Systems, convenience store chain 7‑Eleven, and supermarket chain Hannaford Brothers.[45]
  • In December 2009, an attacker breached a RockYou plaintext database containing the unencrypted usernames and passwords of about 32 million users using an SQL injection attack.[46]
  • On July 2010, a South American security researcher who goes by the handle "Ch Russo" obtained sensitive user information from popular BitTorrent site The Pirate Bay. He gained access to the site's administrative control panel and exploited a SQL injection vulnerability that enabled him to collect user account information, including IP addresses, MD5 password hashes and records of which torrents individual users have uploaded.[47]
  • From July 24 to 26, 2010, attackers from Japan and China used an SQL injection to gain access to customers' credit card data from Neo Beat, an Osaka-based company that runs a large online supermarket site. The attack also affected seven business partners including supermarket chains Izumiya Co, Maruetsu Inc, and Ryukyu Jusco Co. The theft of data affected a reported 12,191 customers. As of August 14, 2010 it was reported that there have been more than 300 cases of credit card information being used by third parties to purchase goods and services in China.
  • On September 19 during the 2010 Swedish general election a voter attempted a code injection by hand writing SQL commands as part of a write‑in vote.[48]
  • On November 8, 2010 the British Royal Navy website was compromised by a Romanian hacker named TinKode using SQL injection.[49][50]
  • On February 5, 2011 HBGary, a technology security firm, was broken into by LulzSec using a SQL injection in their CMS-driven website[51]
  • On March 27, 2011, mysql.com, the official homepage for MySQL, was compromised by a hacker using SQL blind injection[52]
  • On April 11, 2011, Barracuda Networks was compromised using an SQL injection flaw. Email addresses and usernames of employees were among the information obtained.[53]
  • Over a period of 4 hours on April 27, 2011, an automated SQL injection attack occurred on Broadband Reports website that was able to extract 8% of the username/password pairs: 8,000 random accounts of the 9,000 active and 90,000 old or inactive accounts.[54][55][56]
  • On June 1, 2011, "hacktivists" of the group LulzSec were accused of using SQLI to steal coupons, download keys, and passwords that were stored in plaintext on Sony's website, accessing the personal information of a million users.[57][58]
  • In June 2011, PBS was hacked, mostly likely through use of SQL injection; the full process used by hackers to execute SQL injections was described in this Imperva blog.[59]
  • In May 2012, the website for Wurm Online, a massively multiplayer online game, was shut down from an SQL injection while the site was being updated.[60]
  • In July 2012 a hacker group was reported to have stolen 450,000 login credentials from Yahoo!. The logins were stored in plain text and were allegedly taken from a Yahoo subdomain, Yahoo! Voices. The group breached Yahoo's security by using a "union-based SQL injection technique".[61][62]
  • On October 1, 2012, a hacker group called "Team GhostShell" published the personal records of students, faculty, employees, and alumni from 53 universities including Harvard, Princeton, Stanford, Cornell, Johns Hopkins, and the University of Zurich on pastebin.com. The hackers claimed that they were trying to "raise awareness towards the changes made in today’s education", bemoaning changing education laws in Europe and increases in tuition in the United States.[63]
  • On June 27, 2013, hacker group "RedHack" breached Istanbul Administration Site.[64] They claimed that, they’ve been able to erase people's debts to water, gas, Internet, electricity, and telephone companies. Additionally, they published admin user name and password for other citizens to log in and clear their debts early morning. They announced the news from Twitter.[65]
  • On November 4, 2013, hacktivist group "RaptorSwag" allegedly compromised 71 Chinese government databases using an SQL injection attack on the Chinese Chamber of International Commerce. The leaked data was posted publicly in cooperation with Anonymous.[66]
  • On February 2, 2014, AVS TV had 40,000 accounts leaked by a hacking group called @deletesec [67]
  • On February 21, 2014, United Nations Internet Governance Forum had 3,215 account details leaked.[68]
  • On February 21, 2014, Hackers of a group called @deletesec hacked Spirol International after allegedly threatening to have the hackers arrested for reporting the security vulnerability. 70,000 user details were exposed over this conflict.[69]
  • On March 7, 2014, officials at Johns Hopkins University publicly announced that their Biomedical Engineering Servers had become victim to an SQL injection attack carried out by an Anonymous hacker named "Hooky" and aligned with hacktivist group "RaptorSwag". The hackers compromised personal details of 878 students and staff, posting a press release and the leaked data on the internet.[70]
  • In August 2014, Milwaukee-based computer security company Hold Security disclosed that it uncovered a theft of confidential information from nearly 420,000 websites through SQL injections.[71] The New York Times confirmed this finding by hiring a security expert to check the claim.[72]
  • In October 2015, SQL injection was believed to be used to attack the British telecommunications company Talk Talk's servers, stealing the personal details of up to four million customers.[73]

Nella cultura popolare[edit]

  • Unauthorized login to web sites by means of SQL injection forms the basis of one of the subplots in J.K. Rowling's novel The Casual Vacancy, published in 2012.
  • An xkcd cartoon involved a character "Robert'); DROP TABLE students;--" named to carry out a SQL injection. As a result of this cartoon, SQL injection is sometimes informally referred to as 'Bobby Tables'.[74][75]
  • In 2014, an individual in Poland legally renamed his business to Dariusz Jakubowski x'; DROP TABLE users; SELECT '1 in an attempt to disrupt operation of spammers’ harvesting bots.[76]

Vedi anche[edit]

Riferimenti[edit]

  1. ^ Microsoft. "SQL Injection". Retrieved August 4, 2013. SQL injection is an attack in which malicious code is inserted into strings that are later passed to an instance of SQL Server for parsing and execution. Any procedure that constructs SQL statements should be reviewed for injection vulnerabilities because SQL Server will execute all syntactically valid queries that it receives. Even parameterized data can be manipulated by a skilled and determined attacker.
  2. ^ Imperva (July 2012). "Imperva Web Application Attack Report" (PDF). Retrieved August 4, 2013. Retailers suffer 2x as many SQL injection attacks as other industries. / While most web applications receive 4 or more web attack campaigns per month, some websites are constantly under attack. / One observed website was under attack 176 out of 180 days, or 98% of the time.
  3. ^ Sean Michael Kerner (November 25, 2013). "How Was SQL Injection Discovered? The researcher once known as Rain Forrest Puppy explains how he discovered the first SQL injection more than 15 years ago".
  4. ^ Jeff Forristal (signing as rain.forest.puppy) (December 25, 1998). "NT Web Technology Vulnerabilities". Phrack Magazine. 8 (54 (article 8)).
  5. ^ "Category:OWASP Top Ten Project". OWASP. Retrieved June 3, 2011.
  6. ^ "Category:OWASP Top Ten Project". OWASP. Retrieved August 13, 2013.
  7. ^ "WHID 2007-60: The blog of a Cambridge University security team hacked". Xiom. Retrieved June 3, 2011.
  8. ^ "WHID 2009-1: Gaza conflict cyber war". Xiom. Retrieved June 3, 2011.
  9. ^ [1] Archived June 18, 2009, at the Wayback Machine
  10. ^ "Third Wave of Web Attacks Not the Last". Dark Reading. Retrieved July 29, 2012.
  11. ^ Danchev, Dancho (January 23, 2007). "Mind Streams of Information Security Knowledge: Social Engineering and Malware". Ddanchev.blogspot.com. Retrieved June 3, 2011.
  12. ^ Deltchev, Krassen. "New Web 2.0 Attacks". B.Sc. Thesis. Ruhr-University Bochum. Retrieved February 18, 2010.
  13. ^ IBM Informix Guide to SQL: Syntax. Overview of SQL Syntax > How to Enter SQL Comments, IBM
  14. ^ "Using SQLBrute to brute force data from a blind SQL injection point". Justin Clarke. Archived from the original on June 14, 2008. Retrieved October 18, 2008.
  15. ^ macd3v. "Blind SQL Injection tutorial". Retrieved December 6, 2012.{{cite web}}: CS1 maint: numeric names: authors list (link)
  16. ^ Andrey Rassokhin; Dmitry Oleksyuk. "TDSS botnet: full disclosure". Retrieved December 6, 2012.
  17. ^ "Questions for TalkTalk - BBC News". BBC News. Retrieved October 26, 2015.
  18. ^ "SQL Injection Prevention Cheat Sheet". Open Web Application Security Project. Retrieved March 3, 2012.
  19. ^ "mysqli->real_escape_string - PHP Manual". PHP.net.
  20. ^ "Addslashes - PHP Manual". PHP.net.
  21. ^ "Transparent query layer for MySQL". Robert Eisele. November 8, 2010.
  22. ^ http://php.net/manual/en/function.bin2hex.php
  23. ^ http://php.net/manual/en/function.dechex.php
  24. ^ https://www.mysql.com/
  25. ^ https://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_unhex
  26. ^ https://dev.mysql.com/doc/refman/5.0/en/type-conversion.html
  27. ^ http://php.net/manual/en/function.mysql-real-escape-string.php
  28. ^ http://www.ascii-code.com/
  29. ^ http://www.asciitable.com/
  30. ^ http://stackoverflow.com/questions/22567944/is-hexing-input-sufficient-to-sanitize-sql-queries
  31. ^ http://blog.uzitech.com/2014/06/use-bin2hex-and-unhex-as-simple-sql.html
  32. ^ http://demo.sabaidiscuss.com/questions/question/best-way-to-prevent-sql-injection
  33. ^ https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2576&lngWId=8
  34. ^ "Guesswork Plagues Web Hole Reporting". SecurityFocus. March 6, 2002.
  35. ^ "WHID 2005-46: Teen uses SQL injection to break to a security magazine web site". Web Application Security Consortium. November 1, 2005. Retrieved December 1, 2009.
  36. ^ "WHID 2006-3: Russian hackers broke into a RI GOV website". Web Application Security Consortium. January 13, 2006. Retrieved May 16, 2008.
  37. ^ "WHID 2006-27: SQL Injection in incredibleindia.org". Web Application Security Consortium. March 29, 2006. Retrieved March 12, 2010.
  38. ^ Robert (June 29, 2007). "Hacker Defaces Microsoft U.K. Web Page". cgisecurity.net. Retrieved May 16, 2008.
  39. ^ Keith Ward (June 29, 2007). "Hacker Defaces Microsoft UK Web Page". Redmond Channel Partner Online. Retrieved May 16, 2008.
  40. ^ a b Sumner Lemon, IDG News Service (May 19, 2008). "Mass SQL Injection Attack Targets Chinese Web Sites". PCWorld. Retrieved May 27, 2008.
  41. ^ Alex Papadimoulis (April 15, 2008). "Oklahoma Leaks Tens of Thousands of Social Security Numbers, Other Sensitive Data". The Daily WTF. Retrieved May 16, 2008.
  42. ^ Michael Zino (May 1, 2008). "ASCII Encoded/Binary String Automated SQL Injection Attack".
  43. ^ Giorgio Maone (April 26, 2008). "Mass Attack FAQ".
  44. ^ Gregg Keizer (April 25, 2008). "Huge Web hack attack infects 500,000 pages". Retrieved October 16, 2015.
  45. ^ "US man 'stole 130m card numbers'". BBC. August 17, 2009. Retrieved August 17, 2009.
  46. ^ O'Dell, Jolie (December 16, 2009). "RockYou Hacker - 30% of Sites Store Plain Text Passwords". New York Times. Retrieved May 23, 2010.
  47. ^ "The pirate bay attack". July 7, 2010.
  48. ^ "Did Little Bobby Tables migrate to Sweden?". Alicebobandmallory.com. Retrieved June 3, 2011.
  49. ^ Royal Navy website attacked by Romanian hacker BBC News, 8-11-10, Accessed November 2010
  50. ^ Sam Kiley (November 25, 2010). "Super Virus A Target For Cyber Terrorists". Retrieved November 25, 2010.
  51. ^ "We Are Anonymous: Inside the Hacker World of LulzSec" (PDF). Little, Brown and Company.
  52. ^ "MySQL.com compromised". sucuri.
  53. ^ "Hacker breaks into Barracuda Networks database".
  54. ^ "site user password intrusion info". Dslreports.com. Retrieved June 3, 2011.
  55. ^ "DSLReports says member information stolen". Cnet News. April 28, 2011. Retrieved April 29, 2011.
  56. ^ "DSLReports.com breach exposed more than 100,000 accounts". The Tech Herald. April 29, 2011. Retrieved April 29, 2011.
  57. ^ "LulzSec hacks Sony Pictures, reveals 1m passwords unguarded", electronista.com, June 2, 2011
  58. ^ Ridge Shan (June 6, 2011), "LulzSec Hacker Arrested, Group Leaks Sony Database", The Epoch Times
  59. ^ "Imperva.com: PBS Hacked - How Hackers Probably Did It". Retrieved July 1, 2011.
  60. ^ "Wurm Online is Restructuring". May 11, 2012.
  61. ^ Chenda Ngak. "Yahoo reportedly hacked: Is your account safe?", CBS News. July 12, 2012. Retrieved July 16, 2012.
  62. ^ http://www.zdnet.com/450000-user-passwords-leaked-in-yahoo-breach-7000000772/
  63. ^ Perlroth, Nicole (October 3, 2012). "Hackers Breach 53 Universities and Dump Thousands of Personal Records Online". New York Times.
  64. ^ "RedHack Breaches Istanbul Administration Site, Hackers Claim to Have Erased Debts".
  65. ^ "Redhack tweet about their achievement".
  66. ^ http://news.softpedia.com/news/Hackers-Leak-Data-Allegedly-Stolen-from-Chinese-Chamber-of-Commerce-Website-396936.shtml
  67. ^ http://www.maurihackers.info/2014/02/40000-avs-tv-accounts-leaked.html
  68. ^ http://www.batblue.com/united-nations-internet-governance-forum-breached/
  69. ^ http://news.softpedia.com/news/Details-of-70-000-Users-Leaked-by-Hackers-From-Systems-of-SPIROL-International-428669.shtml
  70. ^ http://articles.baltimoresun.com/2014-03-07/news/bs-md-hopkins-servers-hacked-20140306_1_engineering-students-identity-theft-server
  71. ^ Damon Poeter. 'Close-Knit' Russian Hacker Gang Hoards 1.2 Billion ID Creds, PC Magazine, August 5, 2014
  72. ^ Nicole Perlroth. Russian Gang Amasses Over a Billion Internet Passwords, The New York Times, August 5, 2014.
  73. ^ Mobile News article
  74. ^ Munroe, Randall. "XKCD: Exploits Of A Mom". Retrieved February 26, 2013.
  75. ^ "Bobby Tables: A guide to preventing SQL injection". Retrieved October 6, 2013.
  76. ^ "Jego firma ma w nazwie SQL injection. Nie zazdrościmy tym, którzy będą go fakturowali ;)". Niebezpiecznik (in Polish). September 11, 2014. Retrieved September 26, 2014.

External links[edit]

Category:Data management Category:Injection exploits Category:SQL Category:Articles with example SQL code Category:Computer security exploits