Security: add allowed_classes to Form::getSessionValidationResult() unserialize()#11985
Open
XananasX7 wants to merge 1 commit into
Open
Security: add allowed_classes to Form::getSessionValidationResult() unserialize()#11985XananasX7 wants to merge 1 commit into
XananasX7 wants to merge 1 commit into
Conversation
…nserialize()
Form::getSessionValidationResult() deserializes a ValidationResult object
stored in the user session without restricting allowed_classes. Since PHP
session data can be influenced by an attacker (e.g. session fixation,
session storage compromise, or a separate injection bug), this creates a
PHP Object Injection (POI) vector where an attacker can craft a serialized
payload containing arbitrary class instances.
The deserialized value is always expected to be a ValidationResult, so add
an explicit allowed_classes allowlist:
unserialize($resultData, ['allowed_classes' => [ValidationResult::class]])
This limits instantiation to only the expected class, preventing exploitation
via gadget chains even if an attacker controls the session content.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add explicit
allowed_classesrestriction to theunserialize()call inForm::getSessionValidationResult().Vulnerability
Form::getSessionValidationResult()(Form.php line 505) deserializes aValidationResultfrom session storage without anallowed_classesrestriction:The session data is user-controlled (read from
FormInfo.{FormName}.resultin the user's session). An attacker who can control session contents — via session fixation, a storage backend compromise, or a chained injection bug — can supply a crafted serialized payload that instantiates arbitrary PHP classes, exploiting gadget chains present in the application's dependencies.Fix
Restrict deserialization to only the expected class:
The deserialized value is always expected to be a
ValidationResult. ThesetSessionValidationResult()method on the same class only ever stores aValidationResultobject, confirming the allowlist is complete.References
allowed_classes: https://www.php.net/manual/en/function.unserialize.php