Last active
June 29, 2022 17:20
-
-
Save mortenson/7fdcb586104514bd38996b7f6093a004 to your computer and use it in GitHub Desktop.
An idea about how to secure unserialize() calls in PHP dependencies that aren't using allowed_classes.
This file contains 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
<?php | |
namespace Some\Namespace\I\Dont\Trust; | |
function unserialize($data, array $options = []) { | |
if (empty($options)) { | |
$options = [ | |
'allowed_classes' => [ | |
\DateTime::class, // Set to classes used in namespace. | |
], | |
]; | |
} | |
return \unserialize($data, $options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment