php-injection-audit

Audit PHP source code for SQL, command, SSRF, expression, NoSQL, and LDAP injection vulnerabilities.

1.7k|238|Updated Dec 7, 2019
One-click install
npx skills add https://github.com/wgpsec/AboutSecurity --skill php-injection-audit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: php-injection-audit
Source: https://github.com/wgpsec/AboutSecurity/tree/main/skills/code-audit/php/php-injection-audit
Command: npx skills add https://github.com/wgpsec/AboutSecurity --skill php-injection-audit

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

White-box auditors need a systematic way to determine whether injection vulnerabilities actually exist in PHP source code by verifying whether filtering along Source-to-Sink data flow paths is sufficient, rather than guessing from black-box behavior.

Core Features & Use Cases

  • Six Injection Types Covered: SQL injection (PDO/MySQLi/ORM Raw methods), command injection (exec/system/proc_open), SSRF (curl/file_get_contents/SoapClient), expression injection (eval/assert/preg_replace /e), NoSQL injection (MongoDB operators and $where), and LDAP injection (filter string concatenation).
  • Evidence-Driven Workflow: Consumes EVID_* data flow evidence from the php-audit-pipeline, evaluates filter effectiveness (e.g., addslashes vs GBK wide-byte, escapeshellarg bypass scenarios), and assigns severity using the unified Score = R0.40 + I0.35 + C*0.25 formula.
  • Use Case: During a Laravel application audit, use this Skill to review whereRaw/orderByRaw call sites, confirm whether user input bypasses ORM parameterization, and produce confirmed or pending-verification findings with concrete bypass reasoning.

Quick Start

Audit this PHP codebase for injection vulnerabilities using the EVID evidence from php-audit-pipeline and report confirmed SQL, command, and SSRF injection points with severity scores.

Frequently Asked Questions about php-injection-audit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit PHP code for SQL injection vulnerabilities?

Trace user input into SQL execution sinks like PDO::query, mysqli_query, and ORM Raw methods such as whereRaw or orderByRaw. Confirm whether prepare/execute parameter binding is complete, since string concatenation or sprintf %s interpolation into queries remains injectable even with partial escaping.

How to detect command injection in PHP source code?

Search for exec, system, shell_exec, passthru, proc_open, popen, and backtick expressions, then check whether each argument segment is escaped. Note that combining escapeshellarg with escapeshellcmd can break quote pairing, while proc_open array mode avoids shell parsing entirely.

Does escapeshellarg fully prevent PHP command injection?

escapeshellarg alone is usually effective, but it can be bypassed when combined with escapeshellcmd, under certain multibyte locales like GBK, or when the argument abuses command flags rather than shell metacharacters. Multi-parameter commands still need every segment individually escaped.

Can ORM parameterization still allow SQL injection in Laravel?

Yes. Raw methods like whereRaw, havingRaw, orderByRaw, and selectRaw are not protected by ORM parameterization when variables are concatenated inside them. Dynamic ORDER BY and LIMIT clauses also cannot use bound parameters and require whitelisting or intval casting.

What are the limitations of source-level injection auditing?

Source-level auditing only determines whether an injection is exploitable in code; it does not construct payloads or bypass WAFs at runtime, which belong to black-box exploitation. Sinks without EVID data flow evidence can only be marked as pending verification.