In SA-CORE-2019-003 code below was introduced in MapItem.php and introduced a bug which throws fatal errors because of incomplete object which previously worked.
if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
$values = unserialize($values, ['allowed_classes' => FALSE]);
}
else {
$values = unserialize($values);
}
if class is passed like for example in commerce logs.
https://www.drupal.org/forum/support/post-installation/2019-02-28/fatal-....
Returns fatal error like below.
Fatal error: method_exists(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Drupal\Core\StringTranslation\TranslatableMarkup" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in ...
I think we can allow TranslateableMarkup here on the list of allowed classes as it is considered that
"Strings sanitized by t() are automatically marked safe" as listed here
This would solve issues below:
https://www.drupal.org/project/commerce/issues/3040333#comment-13022686
https://www.drupal.org/forum/support/post-installation/2019-02-28/fatal-....
Providing patch for this.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 3045173-nr-bot.txt | 825 bytes | needs-review-queue-bot |
| #11 | 3045173-11.patch | 839 bytes | mrinalini9 |
| #8 | 3045173-8.patch | 839 bytes | dsdeiz |
| mapitem_unserialize.patch | 917 bytes | xsdx |
Comments
Comment #2
xsdx commentedComment #3
xsdx commentedComment #4
agolubic commented@xSDx Thanks! Tested, patch is working and it resolve issue with Fatal error on commerce log (described in https://www.drupal.org/forum/support/post-installation/2019-02-28/fatal-...)
Comment #5
alexpottWe'd need test coverage of this change to make sure it works and also to make sure we don't break it in the future. Also we need a security review to make sure this is inline with the security issue.
For what is is worth \Drupal\Core\StringTranslation\TranslatableMarkup::__sleep() looks like it makes TranslatableMarkup safe to serialise as only a string and couple of arrays are serialised - but this can get very complex quickly and needs to be thought about in depth.
I've pinged this issue in the private security channel and commented in the original security issue.
Comment #6
xjmI wonder if Commerce could refactor or extend MapItem to allow the class, instead of changing it in core? I think core should be as restrictive as possible by default as a principle.
Comment #8
dsdeiz commentedRerolling for 8.8.x.
Comment #10
mrinalini9 commentedComment #11
mrinalini9 commentedRerolled patch to 9.1.x.
Comment #17
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.