Add ['allowed_classes' => FALSE] to unserialize() in migrate modules
2 unresolved threads
Closes #3525170
Merge request reports
Activity
added 1 commit
- 19637ff8 - Allow stdClass in DrupalSqlBase::variableGet()
65 65 if (isset($cached['id'])) { 66 66 // Explicitly unserialize this to create a new object 67 67 // instance. 68 $definitions[$cached['id']] = unserialize($cached['content']); 68 $definitions[$cached['id']] = unserialize($cached['content'], ['allowed_classes' => FALSE]); - Comment on lines -68 to +68
This use of
unserialize()
seems like the most likely to need classes other thanstdClass
, since it is parsing annotations from doc blocks. But that also means this is the safest place to useunserialize()
: it is being applied to data extracted from PHP classes in the codebase, not from the database.Of course, if we can restrict the allowed classes, we should do that, since it is safer if we do not have to worry about it.
173 173 catch (\Exception) { 174 174 $result = FALSE; 175 175 } 176 return $result !== FALSE ? unserialize($result) : $default; 176 return $result !== FALSE ? unserialize($result, ['allowed_classes' => ['stdClass']]) : $default;
Please register or sign in to reply