Skip to content

[FilesUploadHandler] Add preliminary check for path traversal#10382

Merged
driusan merged 1 commit intoaces:mainfrom
driusan:FilesUploadPaths
Apr 1, 2026
Merged

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

Conversation

@driusan
Copy link
Copy Markdown
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
Copy link
Copy Markdown
Contributor

@GeorgeMurad GeorgeMurad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@driusan driusan merged commit af14bec into aces:main Apr 1, 2026
39 of 40 checks passed
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.

2 participants