Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions flight/net/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ public function moveTo(string $targetPath): void
throw new Exception($this->getUploadErrorMessage($this->error));
}

if (is_writeable(dirname($targetPath)) === false) {
throw new Exception('Target directory is not writable');
}

// Prevent path traversal attacks
if (strpos($targetPath, '..') !== false) {
throw new Exception('Invalid target path: contains directory traversal');
}

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

// Prevent absolute paths (basic check for Unix/Windows)
if ($targetPath[0] === '/' || (strlen($targetPath) > 1 && $targetPath[1] === ':')) {
throw new Exception('Invalid target path: absolute paths not allowed');
Expand Down
Loading