phptaint
Security-focused PHP lexer, parser, and taint analysis engine with configurable sink registries.
phptaint is designed for security tooling rather than full-fidelity PHP compilation. It parses the PHP constructs that matter for taint analysis, tracks flows from superglobals into sinks, supports framework presets, and now loads custom registry rules from TOML.
Features
- PHP lexer with span tracking
- AST and parser for security-relevant PHP constructs
- Taint analysis across assignments, calls, methods, hooks, and user-defined functions
- Built-in registries for
php_core,wordpress, andlaravel - TOML-backed custom sink and sanitizer registry loading
- Support for modern constructs including
match,enum, andreadonly - Single-file and multi-file analysis
Installation
[]
= "0.1"
Quick Start
use ;
let findings = analyze;
assert!;
Modern PHP Constructs
The parser intentionally supports a focused subset of modern PHP that commonly appears in real applications and plugins:
matchexpressionsenumdeclarations, including backed enumsreadonly classdeclarations and readonly property modifiers- nullsafe calls, closures, arrow functions, hooks, and common control flow
Example:
use ;
let findings = analyze;
assert!;
Built-In Registries
Use the built-in presets directly:
use ;
let source = r#"<?php
$url = $_GET['redirect'];
wp_redirect($url);
"#;
let findings = analyze;
assert!;
TOML Registry Configuration
Custom sinks and sanitizers can now be loaded from TOML with RegistryFile:
use ;
let registry = from_toml?
.into_registry?;
let findings = analyze;
assert!;
# Ok::
Multi-File Analysis
use ;
let findings = analyze_multi;
assert!;
Examples
Run the bundled examples:
Development
cargo fmtcargo check --all-targetscargo test
License
MIT