php-file-write-audit

Trace user input to file-write sinks in PHP applications.

386|38|Updated Mar 24, 2026
One-click install
npx skills add https://github.com/0xShe/PHP-Code-Audit-Skill --skill php-file-write-audit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: php-file-write-audit
Source: https://github.com/0xShe/PHP-Code-Audit-Skill/tree/main/php-file-write-audit
Command: npx skills add https://github.com/0xShe/PHP-Code-Audit-Skill --skill php-file-write-audit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill analyzes PHP project source code to identify and validate arbitrary file write vulnerabilities by tracing user-controlled data from input to sink, validating path traversal to final write targets, and assessing whether newly written content could be executed.

Core Features & Use Cases

  • Write sink detection: identify writes to disk via functions like file_put_contents, fwrite, stream_write, fopen in write or append modes, and rename/copy-based write paths.
  • Path traversal and normalization checks: evaluate how base directories are constructed, detect traversal patterns, and verify final resolved path remains within allowed base.
  • Content origin tracing: map input sources (GET/POST/COOKIE/Upload) to their use in write operations to assess exploitability.
  • Execution feasibility assessment: determine if the write destination is within web-accessible or executable directories and whether execution is possible.
  • Use Case: Audit a PHP web application to catch unconstrained user writes that could lead to remote file inclusion or code execution.

Quick Start

Run the audit against your PHP codebase to trace user data through write sinks to potential targets and report on executable risk.

Frequently Asked Questions about php-file-write-audit

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

FAQPage Schema
How do I detect arbitrary file write vulnerabilities in PHP source code?

To detect arbitrary file write vulnerabilities in PHP, trace user-controlled input from GET, POST, or COOKIE data to write sinks like file_put_contents and fwrite, validating path traversal. This process identifies unconstrained writes that could lead to remote code execution.

What is path traversal in PHP file write operations?

Path traversal in PHP file write operations occurs when user-controlled data manipulates the target path of functions like fopen or copy, escaping the intended base directory. Normalization checks verify that the final resolved path remains safely within allowed boundaries.

How do I audit PHP write sinks for remote code execution risk?

Audit PHP write sinks for remote code execution by mapping content origins to user input and assessing if the destination falls within web-accessible or executable directories. This determines whether newly written files can be triggered to execute malicious payloads.

Can I trace user input to file_put_contents sinks during a PHP security audit?

Yes, you can trace user input from sources like uploads and cookies to file_put_contents sinks during a PHP security audit. Content origin mapping verifies if attacker-controlled data directly influences the text being written to disk.

Does this file write audit work with PHP rename and copy operations?

Yes, this file write audit works with PHP rename and copy operations. It detects write paths initiated through these functions alongside standard write calls like fwrite and stream_write, ensuring comprehensive sink coverage during code reviews.

What are the limitations of static analysis for PHP path traversal detection?

Static analysis for PHP path traversal detection may face limitations with dynamic path construction and complex framework routing obscuring the base directory. It requires clear resolution of destination paths and accurate content source mapping to avoid false positives.