-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add "allowed_classes" argument for unserialize() #9563
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
Conversation
I like this suggestion! 👍 Let's wait to hear what others think. Status: reviewed |
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.
Hmmm, I don’t understand the option - can you explain? From reading, it seems like it will not allow any classes to be deserialized... but I’m sure I’m mistaken.
Hi @weaverryan. Yes, it's a required parameter from version 7.0.0 of PHP. @see http://php.net/manual/en/function.unserialize.php |
It’s not required, right? Just available? |
Sorry, you are right. It's symply recommended for security reasons. |
Can you explain what it does? Why is it useful here? And what does it protect from? Sorry, I’m just not familiar - and the php.net description didn’t help much :) |
@weaverryan it disallows initiating classes from the serialized string. For instance, if a hacker is able to change the serialized string in the session, they are able to set the username for instance to some object. This can pose security issues. Setting it to false gives a php error in this case. |
Thank you @comxd. |
Ah, yes yes. I understand now. I was thinking that this example WAS serializing a User object. But yes, it’s just an array - so it makes sense to restrict a class suddenly being unserialized. |
No description provided.