lib-imap: imap-utf7 - Reject invalid octet in imap_utf7_to_utf8() - #311
Open
nishat-06 wants to merge 1 commit into
Open
lib-imap: imap-utf7 - Reject invalid octet in imap_utf7_to_utf8()#311nishat-06 wants to merge 1 commit into
nishat-06 wants to merge 1 commit into
Conversation
Contributor
|
Hi! Thank you for the submission, is this a vulnerability change as you have not certified that it is not? Also this look a bit like AI assisted submission. |
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.
AI policy
Dovecot allows AI assisted or generated code, but we would like to know if it is such.
Do not include 'Co-Authored-By' header in the commit.
Type of Change
Description
imap_utf7_to_utf8() is supposed to reject invalid mUTF-7, but a raw 8-bit or control octet that appears outside a shift sequence is emitted silently instead: the non-escaped path in imap_utf7_to_utf8_int() (escape_chars is "") falls into the escape branch, runs str_printfa(dest, "%c%02x", '\0', octet) which appends a NUL byte, and still returns success. That disagrees with imap_utf7_is_valid(), which rejects the same input, so a client mailbox name such as
&AAE-\x80(SELECT/CREATE/LIST via client_find_namespace_full) slips past the "not valid mUTF-7" check and yields a name containing an embedded NUL. The fix returns -1 in the non-escaped path, matching the sibling mbase64 failure branch just below it; the escaped API and every valid input are unchanged.Additional Notes
Added test_imap_utf7_raw_octet_after_shift to test-imap-utf7.c. It sweeps every control/8-bit octet placed after a completed shift and asserts both imap_utf7_is_valid() and imap_utf7_to_utf8() reject it. The case fails on the current tree (the octet is accepted with an embedded NUL) and passes with this change, while the existing valid-input and escaped round-trip cases are unaffected.