mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-08 06:56:33 +02:00
Mention the filtered unserialize feature of PHP 7
This commit is contained in:
@@ -48,6 +48,12 @@ libraries like [HTML Purifier][html-purifier] exists for this reason.
|
||||
|
||||
[See Sanitization Filters][2]
|
||||
|
||||
### Unserialization
|
||||
|
||||
It is dangerous to `unserialize()` data from users or other untrusted sources. Doing so can allow malicious users to instantiate objects (with user-defined properties) whose destructors will be executed, **even if the objects themselves aren't used**. You should therefore avoid unserializing untrusted data.
|
||||
|
||||
If you absolutely must unserialize data from untrusted sources, use PHP 7's [`allowed_classes`][unserialize] option to restrict which object types are allowed to be unserialized.
|
||||
|
||||
### Validation
|
||||
|
||||
Validation ensures that foreign input is what you expect. For example, you may want to validate an email address, a
|
||||
@@ -63,3 +69,4 @@ phone number, or age when processing a registration submission.
|
||||
[5]: http://php.net/function.filter-input
|
||||
[6]: http://php.net/security.filesystem.nullbytes
|
||||
[html-purifier]: http://htmlpurifier.org/
|
||||
[unserialize]: https://secure.php.net/manual/en/function.unserialize.php
|
||||
|
Reference in New Issue
Block a user