Skip to content
Access control Disclosed report Advanced

IMAP connection reuse runs requests in the wrong case-sensitive mailbox

libcurl's IMAP connection reuse compared mailbox names case-insensitively, so a request for a differently-cased mailbox name skipped the SELECT and ran against the previously selected mailbox. An attacker who can choose a case-colliding mailbox name could read message data or change flags in another mailbox on a pooled connection.

1rhino2 Follow

Originally disclosed on HackerOne

  • Disclosed after 13 days

When libcurl reuses an authenticated IMAP connection, lib/imap.c:2071-2089 uses curl_strequal() to decide whether the requested mailbox is already selected. RFC 9051 section 5.1 requires clients to work with servers where non-INBOX mailbox names are case-sensitive, while only INBOX is guaranteed to be case-insensitive. On curl 8.21.0 commit 68720b4837284335b2d63cb358f8f6ce65f5bc55 and current master 0ebe0e978535f10f6fe54536ca2e2e6b304a4d5a, sequential requests for Private and private reuse one TCP connection, omit SELECT private, and return PRIVATE_MAILBOX_CANARY for the second request instead of the lowercase mailbox's data. With two separate easy handles sharing one multi connection pool, a second request using UID STORE 1 +FLAGS (\Flagged) also skips SELECT private and changes the flag on the canary in Private; the fixed control selects private first and changes only the lowercase canary. The attachment reproduces the read and STORE cases twice on both revisions, includes distinct-name, exact-same-name, INBOX, and fixed controls, and I used AI to assist the report drafting before personally rerunning every case.

Impact

In a service that pools libcurl IMAP requests under one shared account, an attacker able to request a case-colliding mailbox can read message data from, or change message flags in, the mailbox left selected by a previous request, crossing the application's mailbox boundary.

The original report as published on HackerOne, by 1rhino2. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The connection-reuse check compared the requested mailbox with the currently selected one using a case-insensitive string comparison, although only INBOX is guaranteed case-insensitive.

Impact

In a service pooling libcurl IMAP requests under one shared account, an attacker able to request a case-colliding mailbox could read message data from, or change flags in, the mailbox left selected by a previous request.

What the attacker needed

Shared libcurl IMAP connection pool; attacker controls mailbox name casing; same account used for pooled requests

How it was found

  1. Open a first IMAP request for a mailbox named with one casing, such as Private.
  2. On the same reused connection, issue a second request for the same name in different casing, such as private.
  3. Observe that no SELECT is sent for the second mailbox and the first mailbox's data is returned.
  4. Repeat with two easy handles sharing one multi connection pool and a flag-changing command to see the flag altered in the wrong mailbox.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

IMAP is the protocol mail clients use to read a mailbox on a server. Some servers treat mailbox names as case-sensitive, so 'Private' and 'private' are two different mailboxes. libcurl wrongly treated them as the same, so it kept using the first mailbox and returned its contents for the second request.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by 1rhino2

View all

12 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.