|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80216 imap_mail_compose() does not validate types/encodings
Submitted: 2020-10-10 16:35 UTC Modified: 2020-10-12 09:13 UTC
From: Assigned: cmb (profile)
Status: Closed Package: IMAP related
PHP Version: 7.3Git-2020-10-10 (Git) OS: *
Private report: No CVE-ID: None
 [2020-10-10 16:35 UTC]
If imap_mail_compose() is used to create a multipart MIME message
without specifying explicit types for the individual parts, that
leads to a segfault.  Since the type for the first body defaults
to TYPETEXT, I would expect the individual parts to default to
TYPETEXT as well.

Test script:
$envelope = [
    'from' => '',
    'to' => '',
    'subject' => 'hello',
$body = [[
    'type' => TYPEMULTIPART,
], [
    '' => 'yada yada',
echo imap_mail_compose($envelope, $body);

Expected result:
Subject: hello
MIME-Version: 1.0
Content-Type: MULTIPART/MIXED; BOUNDARY="321-1709-1602347443=:9960"


yada yada

Actual result:


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-10 16:35 UTC]
-Assigned To: +Assigned To: cmb
 [2020-10-12 09:13 UTC]
-Summary: imap_mail_compose() segfaults on multipart w/o part type +Summary: imap_mail_compose() does not validate types/encodings
 [2020-10-12 09:13 UTC]
Actually, it is not just about omitting the type; more generally,
if a type < 0 or >= TYPEMAX is passed, we do OOB reads.  And there
are potential issues where TYPEOTHER < type < TYPEMAX, because
these types *may* not have associated type names, in which case we
segfault as well.

The encoding parameter has basically the same issue.
 [2020-10-12 12:10 UTC]
The following pull request has been associated:

Patch Name: Fix #80216: imap_mail_compose() does not validate types/encodings
On GitHub:
 [2020-10-12 14:32 UTC]
Automatic comment on behalf of
Log: Fix #80216: imap_mail_compose() does not validate types/encodings
 [2020-10-12 14:32 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 11:01:31 2024 UTC