mediawiki/phan-taint-check-plugin
Phan plugin for detecting taint-based security issues in PHP, including XSS, SQL and shell injection, and unsafe serialization. Tracks user-controlled data and checks it’s escaped before output or queries; supports generic PHP and MediaWiki-specific analysis.
composer require --dev mediawiki/phan-taint-check-plugin to add the plugin..phan/config.php), add the plugin to the plugins list:
'vendor/mediawiki/phan-taint-check-plugin/GenericSecurityCheckPlugin.php''vendor/mediawiki/phan-taint-check-plugin/MediaWikiSecurityCheckPlugin.php''quick_mode' => false — critical for the plugin to work.SecurityCheck-LikelyFalsePositive and SecurityCheck-PHPSerializeInjection to suppress_issue_types.vendor/bin/phan -d . --long-progress-bar. Add --analyze-twice for deeper checks.First use case: Scan your app for XSS or SQLi entry points — e.g., tainted
$_GETused inecho,require, or SQL queries.
-y 10), then expand coverage. Use @suppress selectively (see Gotchas).@param-taint $param escapes_html so Phan knows escapeHtml() clears HTML taint.@param-taint $input exec_html to flag functions that output unsanitized user input (triggers warnings if HTML-tainted values are passed).@return-taint htmlnoent to mark return values as safe HTML (e.g., for pre-escaped content).@param-taint $param escapes_sql on custom DB abstraction methods.select() options, ensure $options/$join_cond are arrays literals — the plugin detects taint only in these cases.'@phan-debug-var-taintedness $variableName'; as a string literal in code to see taint state at runtime.@phan-suppress-next-line SecurityCheck-XSS or @suppress in docblocks for known-safe cases (e.g., CLI scripts outputting non-HTML).@return-taint html when safe.@param-taint. E.g., @param-taint $str escapes_html tells Phan your escapeMyHtml() is safe.--analyze-twice catches more issues but may duplicate reports — filter with grep -v "SecurityCheck" if debugging.@phan-file-suppress SecurityCheck-XSS at top of entry scripts.SecurityCheckPlugin to add custom taint types (e.g., custom1 for config injection) via getCustomFuncTaints(). See MediaWikiSecurityCheckPlugin for real-world examples.How can I help you explore Laravel packages today?