[php-src] Issue #19375: Would be nice to have a built-in function for preventing Directory Traversal Attacks
| From: | Patchx | Date: | Tue, 05 Aug 2025 15:28:35 +0000 |
| Subject: | [php-src] Issue #19375: Would be nice to have a built-in function for preventing Directory Traversal Attacks | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250561@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19375
Author: Patchx
### Description
I apologize if this is a duplicate. I searched a bit but didn't see this topic existing in the
issues.
Given the potential security impact of a file_get_contents, unlink, etc call without directory
traversal attack prevention, it would be nice to have some built-in protection, either in the form
of a parameter to these existing types of functions, or a dedicated checker function, such as that
described in https://stackoverflow.com/questions/4205141/preventing-directory-traversal-in-php-but-allowing-paths
It's not hard to implement this per-project, but having something built-in would help more
projects have better security hygiene by default.