PHP Object Injection vulnerability due to misuse of unserialize allowed_classes #555
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I submitted this privately to Google's OSS VRP but they decided it doesn't meet the requirements to be handled as a security issue.
The AMP Toolbox for PHP has a potential PHP Object Injection vulnerability that could be exploited by an attacker that can write files to the system temp directory. (Acknowledging that this is a "high barrier" for the problem to be exploitable - it would require something like an upload form that writes files directly to the temp directory with the attacker's chosen filename.)
A successful exploit could escalate the ability to write to the temp directory. Depending on what Gadget Chains are available in the application, full Remote Code Execution could be achieved.
The vulnerability is caused by an improperly formatted parameter to
unserialize().This passes a second parameter to
unserialize()which is presumably intended to limit the allowed classes that can be unserialized. However, the format of this parameter is incorrect:https://www.php.net/manual/en/function.unserialize.php
The 2nd parameter is an array of options, and there should be an element with the key
allowed_classes. The function call should be:The current implementation does not restrict the classes that can be unserialized and therefore a malicious payload in an appropriately named file in the temp directory could be used to achieve PHP Object Injection.