taint
1.0.0
XSS 코드 (오염 된 문자열)를 감지하는 데 사용되는 PHP 확장 및 SQL 주입 취약점, 쉘 주입 등을 발견하는 데 사용될 수도 있습니다.
아이디어는 https://wiki.php.net/rfc/taint에서 나온 것입니다. 패치를 필요로하지 않는 PHP 확장으로 구현했습니다.
앱이 속도를 늦추기 때문에 제품 env 에서이 확장을 활성화하지 마십시오.
PHP8.0 구현의 합병증으로 인해 Taint는 PHP8.0+와 호환되지 않습니다.
Taint는 PECL 확장자이므로 간단히 설치할 수 있습니다.
pecl install taint
$/path/to/phpize
$./configure --with-php-config=/path/to/php-config/
$make && make install
Taint가 활성화되면 오염 된 문자열을 전달하면 ($ _get, $ _post 또는 $ _cookie) 일부 기능으로 전달하면 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 );위의 예는 다음과 유사한 것을 출력합니다.
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
특정 스크립트의 오류를 숨겨야하는 경우 다음을 수행 할 수 있습니다.
ini_set('taint.error_level', 0);