Repository navigation
harden cache backend unserialize, PubSubHubbub verify token and Lucene fileList() - #248
Open
falkenhawk wants to merge 1 commit into
Open
falkenhawk wants to merge 1 commit into
falkenhawk wants to merge 1 commit into
Conversation
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.
1) Cache backends: no objects from their own stored arrays
Zend_Cache_Backend_Filestores the metadata of each cache entry (expiry, tags, ...) as a serialized array in a file next to the data.Zend_Cache_Backend_TwoLevelsstores each entry as a serialized array (data, lifetime, priority) in both of its backends.Both unserialized these without restrictions. Anyone who can write to the cache - e.g. a shared temp directory, the default
cache_dir, or a shared memcache - could plant serialized objects there, and unserializing them runs code like__wakeup()and__destruct()of classes the app has loaded.Both now unserialize with
allowed_classes => false, and treat anything that is not an array as a cache miss. Before, that ended with a fatal error.These arrays only ever hold strings and numbers, because the cached data is always a string:
Zend_Cache_Coreserializes everything else before it reaches a backend.So nothing changes for normal use. The cached data itself is not affected,
Zend_Cache_Corewithautomatic_serializationunserializes it as before.zf1-future did the same for TwoLevels in Shardj/zf1-future#363, and also removes such broken entries from the backends.
Shardj/zf1-future#595 did it for the File backend, and also for other places that unserialize their own data (Static backend,
Zend_Date,Zend_Locale_Data, OpenId file storages, Lucene).2) PubSubHubbub: random verify token
Zend_Feed_Pubsubhubbub_Subscribergeneratedhub.verify_tokenwithuniqid(rand(), true) . time(), which is based on the current time and a weak random number.The hub sends the token back when it confirms a subscription, so it should not be guessable.
It is now
bin2hex(random_bytes(16)). The token is only ever compared as a whole, so its format does not matter.3) Lucene: listing a removed index directory
Zend_Search_Lucene_Storage_Directory_Filesystem::fileList()did not check whetheropendir()succeeded, e.g. after the directory was removed.readdir(false)then throws aTypeErroron php 8. On php 7 it returnsnull, neverfalse, so the loop never ended.It now returns an empty list, after the warning of
opendir().