taint

Taint is a PHP extension, used for detecting XSS codes

Github星跟蹤圖

Taint

Build Status

php extension used to detect XSS codes(tainted string), And also can be used to spot sql injection vulnerabilities, shell inject, etc.

The idea is from https://wiki.php.net/rfc/taint, I implemented it in a php extension which make the patch no-needed.

Please note that do not enable this extension in product env, since it will slowdown your app.

Requirement

  • PHP-5.2 +

Install

taint is an PECL extension, thus you can simply install it by:

pecl install taint

Compile taint in Linux

$/path/to/phpize
$./configure --with-php-config=/path/to/php-config/
$make && make install

Usage

When taint is enabled, if you pass a tainted string(comes from $_GET, $_POST or $_COOKIE) to some functions, taint will warn you about that.

<?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);

The above example will output something similar to:

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

If you need to hide the errors for a particular script, you can:

ini_set('taint.error_level', 0);

主要指標

概覽
名稱與所有者laruence/taint
主編程語言C
編程語言PHP (語言數: 5)
平台
許可證Other
所有者活动
創建於2012-02-13 11:33:43
推送於2024-07-01 04:24:46
最后一次提交2024-07-01 12:24:46
發布數11
最新版本名稱taint-2.1.0 (發布於 )
第一版名稱taint-1.2.0 (發布於 )
用户参与
星數614
關注者數44
派生數128
提交數187
已啟用問題?
問題數49
打開的問題數17
拉請求數15
打開的拉請求數3
關閉的拉請求數10
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?