IMAP: OAuth sign-in sends an initial response without checking SASL-IR

Open Beginner friendly
#657 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
swift

Research direction

Start in IMAPClient.authenticate and compare the .plain branch, which already checks SASL-IR before using AuthenticateCommand, with the .oauthbearer and .xoauth2 branches, which only check the AUTH= capability. Add a .saslIR check to both OAuth branches that throws IMAPError.capabilityNotSupported when it is missing. Done when a server without SASL-IR produces that error and a server with it still signs in.

Written by the indexing model from the issue text.

Description

Summary

With the work for #535, IMAPClient.authenticate sends an XOAUTH2 or OAUTHBEARER credential on the AUTHENTICATE line after checking only that the mechanism is advertised. It doesn't check SASL-IR, the capability that allows a response on that line at all.

(Found by reading the code.)

Details

The .plain branch checks SASL-IR before using AuthenticateCommand. The .oauthbearer and .xoauth2 branches check AUTH=OAUTHBEARER or AUTH=XOAUTH2 and nothing else. There is also no path for a server without SASL-IR, where the response has to be sent after the server's empty challenge.

Gmail isn't affected: the capability list in Google's XOAUTH2 document includes SASL-IR.

Expected behavior

Without SASL-IR, the client either refuses to sign in and names the missing capability, or uses the exchange without an initial response: send AUTHENTICATE <mechanism>, wait for the empty challenge, then send the response on its own line.

Suggested fix

Check .saslIR in both OAuth branches and throw IMAPError.capabilityNotSupported when it's missing. Supporting the exchange without an initial response can follow if a provider needs it.

References

  • RFC 4959, section 3: "clients that implement this extension MUST NOT send an initial client response to servers that do not advertise the SASL-IR capability."
  • RFC 4959, section 3: "If either the client or the server do not support the SASL-IR capability, a mechanism which uses an initial client response is negotiated using the challenge/response exchange described in [RFC3501], with an initial zero-length server challenge."

In thunderbird-android

Links are pinned to ac1f0e8.

Dominant language
Swift
Stars
1.3k
Forks
51
Avg merge
1d 7h
Merged PRs (30d)
33

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thunderbird/thunderbird-ios

All issues in thunderbird/thunderbird-ios

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.