Skip to content
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

Deserialization of untrusted data #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xgin
Copy link

@xgin xgin commented Nov 22, 2021

I want to resolve ZDI-20-1051 vulnerability (additional details) using json serialization when possible and the list of allowed classes in other cases.

@xgin xgin force-pushed the unserialize-untrusted-data branch from 9992f93 to 2682273 Compare November 22, 2021 21:10
@@ -811,7 +811,7 @@ public function buildAndSendMessage(
));

/* Add preferred reply language(s). */
if ($lang = @unserialize($prefs->getValue('reply_lang'))) {
if ($lang = @unserialize($prefs->getValue('reply_lang'), array('allowed_classes' => false))) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find a way to set a value of this preference. Is it used available anywhere?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an advanced preference in the "Compose" preference group.

@@ -577,7 +580,7 @@ protected function _upgradeStationeryToTemplates()
{
global $injector, $prefs;

$slist = @unserialize($prefs->getValue('stationery'));
$slist = @unserialize($prefs->getValue('stationery'), array('allowed_classes' => false));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a deprecation policy, when this property can be removed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already removed, as a settable preference. We don't remove migrations though.

@yunosh
Copy link
Member

yunosh commented Jan 12, 2022

The allowed_classes option is added with PHP 7.0, so we can only use this in IMP 7. For IMP 6, we need to find a different solution. Or at least do a version check.

Copy link

@tribut tribut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch appears to be broken as-is. See tribut@2e27df5, tribut@8a81c3b and tribut@2a9f221, maybe more additions are needed.

$ob = @unserialize($ob, array('allowed_classes' => array(
'IMP_Mailbox_List_Virtual',
'IMP_Mailbox_List_Pop3',
'IMP_Mailbox_List',
Copy link

@tribut tribut Mar 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to include 'IMP_Mailbox'. In our tests, applying this patch without it, broke viewing messages.

'IMP_Flag_Imap_Forwarded',
'IMP_Flag_Imap_Junk',
'IMP_Flag_Imap_NotJunk',
'IMP_Flag_Imap_Seen',
Copy link

@tribut tribut Mar 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to include 'IMP_Flag_User' as well as the 'IMP_Flag_System_' classes (not sure about all of them, we've seen errors without IMP_Flag_System_Unseen at least).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants