PHP extension--taint detect hidden vulnerabilities

Source: Internet
Author: User
Tags taint tainted

Brief introduction

Taint can be used to detect hidden XSS code, SQL injection, Shell injection and other vulnerabilities, and these vulnerabilities to use static analysis tools to troubleshoot, such as the following example:

<?php   echo $_GET["name"];?>

For requests:

http://localhost/?name=222

Static analysis tools, often powerless, but taint can accurately burst out of this type of problem.

Warning: Main::test() [function.echo]: Attempt to echo a string that might be tainted in
Taint Installation
wget http://pecl.php.net/get/taint-1.2.2.tgztar zxvf taint-1.2.2.tgzcd taint-1.2.2/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmake && make install
Configure PHP.ini
[taint]extension=taint.sotaint.enable=1taint.error_level=E_WARNING
Run results
php -i | grep tainttainttaint support => enabledtaint.enable => On => Ontaint.error_level => 2 => 2

# # #附录

A. Validated string
All from G E T , G E T, _post, $_cookie variables, are considered to be tainted String

B. A list of functions/statements detected by taint, taint will give a warning when these functions use tainted string arguments:

1. 输出函数/语句系列    echo    print    printf    file_put_contents2. 文件系统函数    fopen    opendir    basename    dirname    file    pathinfo3. 数据库系列函数/方法    mysql_query    mysqli_query    sqlite_query    sqlite_single_query    oci_parse    Mysqli::query    SqliteDataBase::query    SqliteDataBase::SingleQuery    PDO::query    PDO::prepare4. 命令行系列    system    exec    proc_open    passthru    shell_exec5. 语法结构    eval    include(_once)    require(_once)

C. Functions that eliminate tainted information, and when these functions are called, the tainted string becomes a valid string:

escapeshellcmdhtmlspecialcharsescapeshellcmdaddcslashesaddslashesmysqli_escape_stringmysql_real_escape_stringmysql_escape_stringsqlite_escape_stringPDO::quoteMysqli::escape_stringMysql::real_escape_string

D. Functions/statements that hold tainted information in the call, when these functions/statements are called, the output is also tainted string if the input is tainted string:

=."{$var}.=strvalexplodeimplodesprintfvsprintftrimrtrimltrim


From for notes (Wiz)

PHP extension--taint detect hidden vulnerabilities

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.