Skip to content

Re-add writable directory check for target path#701

Closed
fadrian06 wants to merge 1 commit into
masterfrom
fix-symlink-test-error-in-windows
Closed

Re-add writable directory check for target path#701
fadrian06 wants to merge 1 commit into
masterfrom
fix-symlink-test-error-in-windows

Conversation

@fadrian06

Copy link
Copy Markdown
Contributor

This pull request makes a small but important change to the moveTo method in flight/net/UploadedFile.php. The check for whether the target directory is writable has been moved to occur after the check for directory traversal in the target path. This helps ensure that path validation is performed before checking permissions, improving security and error handling.

  • Security and validation improvements:
    • In moveTo, the check for writable target directory now occurs after verifying that the target path does not contain directory traversal sequences, reducing the risk of improper permission checks on unsafe paths.

Copilot AI review requested due to automatic review settings June 22, 2026 01:15
@fadrian06 fadrian06 closed this Jun 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts validation order in UploadedFile::moveTo() to perform target-path traversal validation before checking whether the destination directory is writable, aiming to improve security and error handling.

Changes:

  • Reordered the target directory writability check to run after the directory traversal check in moveTo().

Comment on lines +139 to +141
if (is_writeable(dirname($targetPath)) === false) {
throw new Exception('Target directory is not writable');
}
}

// Prevent absolute paths (basic check for Unix/Windows)
if ($targetPath[0] === '/' || (strlen($targetPath) > 1 && $targetPath[1] === ':')) {
@fadrian06 fadrian06 deleted the fix-symlink-test-error-in-windows branch June 22, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants