Skip to content

[FilesUploadHandler] Add preliminary check for path traversal#10382

Open
driusan wants to merge 1 commit intoaces:mainfrom
driusan:FilesUploadPaths
Open

[FilesUploadHandler] Add preliminary check for path traversal#10382
driusan wants to merge 1 commit intoaces:mainfrom
driusan:FilesUploadPaths

Conversation

@driusan
Copy link
Collaborator

@driusan driusan commented Feb 25, 2026

The FilesUploadHandler uses basename on the client filename in order to ensure the user can not escape the configured path by uploading a filename containing ../../ (web browsers will generally just provide the filename, but a malicious attacker can try and escape the path.)

However, there is still a theoretical possibility that a caller to FilesUploadHandler does something such as insert the unsanitized value into the database, which can then be misused indirectly.

This adds a preliminary check to ensure the filename provided does not look like a path so that an error is returned and the caller (hopefully) does not do anything with the value if it has anything that looks like a path character. The basename check is maintained.

The FilesUploadHandler uses `basename` on the client filename in order to ensure
the user can not escape the configured path by uploading a filename containing
../../ (ie. web browsers will generally just provide the filename, but a malicious attacker
can try and escape the path.)

However, there is still a theoretical possibility that a caller to FilesUploadHandler
does something such as insert the unsanitized value into the database, which can then be
misused indirectly.

This adds a preliminary check to ensure the filename provided does not look like a path
so that an error is returned and the caller (hopefully) does not do anything with the
value. The basename check is maintained.
@github-actions github-actions bot added the Language: PHP PR or issue that update PHP code label Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: PHP PR or issue that update PHP code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant