Taint

Introdução

Taint é uma extensão usada para detectar códigos XSS (strings contaminadas). E também pode ser usada para identificar vulnerabilidades de injeção de SQL, injeção de shell, etc.

Quando o taint está habilitado, se for passada uma string contaminada (proveniente de $_GET, $_POST ou $_COOKIE) para algumas funções, o taint irá avisar sobre isso.

Exemplo #1 Exemplo de Taint()

<?php
$a = trim($_GET['a']);

$file_name = '/tmp' .  $a;
$output    = "Welcome, {$a} !!!";
$var       = "output";
$sql       = "Select *  from " . $a;
$sql      .= "ooxx";

echo $output;

print $$var;

include $file_name;

mysql_query($sql);
?>

O exemplo acima produzirá algo semelhante a:

Warning: main() [function.echo]: Attempt to echo a string that might be tainted

Warning: main() [function.echo]: Attempt to print a string that might be tainted

Warning: include() [function.include]: File path contains data that might be tainted

Warning: mysql_query() [function.mysql-query]: SQL statement contains data that might be tainted