GHSA-f8ff-652m-j5rx: Path Traversal
Summary
YOURLS versions ≤1.10.4 contain an unauthenticated path traversal vulnerability that allows attackers to include and execute arbitrary PHP files on the server without any credentials.
Details
The vulnerability exists because YOURLS uses URL sanitization functions (yourlssanitizeurl(), yourlsescurl()) to filter request paths, but these functions are designed to clean URLs, not filesystem paths. They preserve / and . characters, allowing ../ sequences to pass through unfiltered.
The unsanitized keyword is then directly concatenated into a filesystem path and passed to fileexists() and later include() operations, enabling path traversal attacks.
Data Flow: HTTP Request URI (with ../) ↓ yourlsgetrequest() (no sanitization) ↓ yourlssanitizeurl() (preserves / and .) ↓ yourlsescurl() (permits / and . via regex) ↓ Keyword extraction (preserves ../) ↓ fileexists(YOURLSPAGEDIR . "/$keyword.php") ← Sink ↓ include(YOURLSPAGEDIR . "/$keyword.php") ← Code Execution
Proof of Concept (POC)
In the concept validation, we assume that the attacker has uploaded a test.php file to the web root directory, but it cannot be accessed directly. (Of course, it could also be any path, such as /tmp/test.php)
Setup Place a test file in web root:
./test.php: php <?php phpinfo(); ?> <img width="502" height="126" alt="image" src="https://github.com/user-attachments/assets/14f33f90-625b-4c65-8abf-244af2385f68" />
Attack Request http GET /../../test HTTP/1.1 Host: target.com Connection: close
Response (Apache Environment)
<img width="1704" height="614" alt="image" src="https://github.com/user-attachments/assets/8750a3c0-a96c-4896-a087-d7b5cfeccd30" />
Impact 1. Remote execution of uploaded PHP files – An attacker uploads a malicious PHP file to an arbitrary location on the server (e.g., via another vulnerability or file upload feature), obtains its absolute path but cannot access it directly. The attacker then leverages this vulnerability to include and execute the PHP file, gaining code execution privileges.
2. Indirect triggering of PHP code injection – If a PHP code injection point exists on the system (e.g., log injection, session injection) but the injected file cannot be accessed directly due to configuration restrictions, the attacker can use this vulnerability to include and execute the injected code, achieving remote command execution or further compromise.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
composer/yourls/yourlsto a version that resolves this vulnerability.Fixed in 1.10.5
Event History
Frequently Asked Questions
Does exploitation require an authenticated YOURLS account?
The advisory summary describes the issue as unauthenticated and says no credentials are required. However, the supplied CVSS vector lists PR:L, so the authentication requirement is inconsistent in the available data.
What must an attacker be able to reach to obtain code execution?
The attacker needs a traversal path that resolves to a PHP file on the server that can be included by YOURLS. The proof-of-concept assumption is that a PHP file has already been uploaded to the web root but is not directly accessible.
Why does URL filtering not prevent traversal in this case?
YOURLS applies URL sanitization and escaping functions to a value later used as a filesystem path. Those functions preserve slash and dot characters, allowing ../ sequences to reach file_exists() and include().