-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check temp path before deleting files in __destruct to avoid Object Injection #664
base: 2
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create a private const TEMP_FILE_PREFIX = 'interventionimage_';
and use that instead of the hardcoded string, and also update line 261 $path = tempnam($tempPath ?? '', 'interventionimage_');
to use the const
Co-authored-by: Steve Boyd <emteknetnz@gmail.com>
Co-authored-by: Steve Boyd <emteknetnz@gmail.com>
$tempPath = $this->getTempPath() ?? ''; | ||
if (str_starts_with(basename($tempPath), InterventionBackend::TEMP_FILE_PREFIX) && file_exists($tempPath)) { | ||
unlink($tempPath); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} |
Description
See #663
Manual testing steps
You can test this manually via cli in various ways, or by doing something crude like adding this to the end of the main index.php
This simulates a PHP Object Injection vulnerability.
You can then pass the payload as a query param, and check whether the target file has been deleted.
e.g. here's a urlencoded payload to remove a test file called now_you_see_me.txt in the docroot:
Issues
Pull request checklist