Steffen Lehmann | 11 Jan 2011 14:39
Picon

POP3 Authorization using SCRAM-SHA-1 fails

POP3 Authorization using SCRAM-SHA-1 fails, because mpop violates the rules 
according to SASL RFC 4422, Section 3:
"Where the mechanism specifies that the server is to return additional
data to the client with a successful outcome and this field is
unavailable or unused, the additional data is sent as a challenge
whose response is empty. After receiving this response, the server
then indicates the successful outcome."

RFC 5034, Section 4:
"Note that POP3 does not allow for additional data to be sent
with a message indicating a successfull outcome (see Section 3.6 of RFC 4422)."

Hence, the following message sequence according to SASL RFC 4422, Section 3 
applies:

C: Request authentication exchange
S: Initial challenge
C: Initial response
<additional challenge/response messages>
S: Additional data challenge
C: Empty Response
S: Outcome of authentication exchange

But mpop behaves as following:

C: AUTH SCRAM-SHA-1  (POP3: command request)
S: +                 (SASL: Initial challenge)
C: biwsb...          (SASL: Initial response; RFC 5802 client-first-message) 
S: + cj01b2t...      (SASL: additional challenge; RFC 5802 server-first-
message)
(Continue reading)

Martin Lambers | 11 Jan 2011 22:32
Picon

Re: POP3 Authorization using SCRAM-SHA-1 fails

Hi Steffen!

On 11/01/11 14:39, Steffen Lehmann wrote:
> POP3 Authorization using SCRAM-SHA-1 fails, because mpop violates the rules 
> according to SASL RFC 4422, Section 3:
> "Where the mechanism specifies that the server is to return additional
> data to the client with a successful outcome and this field is
> unavailable or unused, the additional data is sent as a challenge
> whose response is empty. After receiving this response, the server
> then indicates the successful outcome."
> 
> RFC 5034, Section 4:
> "Note that POP3 does not allow for additional data to be sent
> with a message indicating a successfull outcome (see Section 3.6 of RFC 4422)."
> 
> Hence, the following message sequence according to SASL RFC 4422, Section 3 
> applies:
> 
> C: Request authentication exchange
> S: Initial challenge
> C: Initial response
> <additional challenge/response messages>
> S: Additional data challenge
> C: Empty Response
> S: Outcome of authentication exchange
> 
> But mpop behaves as following:
> 
> C: AUTH SCRAM-SHA-1  (POP3: command request)
> S: +                 (SASL: Initial challenge)
(Continue reading)

Simon Josefsson | 11 Jan 2011 22:36
Favicon
Gravatar

Re: POP3 Authorization using SCRAM-SHA-1 fails

Martin Lambers <marlam <at> marlam.de> writes:

>>From your analysis, it seems that SCRAM-SHA-1 needs the same exception
> rule that DIGEST-MD5 needs, so the attached patch might fix the problem.
> Would you please test it?
...
> -    /* For DIGEST-MD5, we need to send an empty answer to the last 334
> -     * response before we get 235. */
> -    if (strcmp(auth_mech, "DIGEST-MD5") == 0)
> +    /* For DIGEST-MD5 and SCRAM-SHA-1, we need to send an empty answer to the
> +     * last response before we get an OK. */
> +    if (strcmp(auth_mech, "DIGEST-MD5") == 0
> +            || strcmp(auth_mech, "SCRAM-SHA-1") == 0)

This looks a bit strange -- it shouldn't special-case SASL mechanisms,
but just use the normal SASL state machine.  You can use the return
value from gsasl_step function to guide you when to quit the loop,
although you need to observe that each challenge has a response.

This is just an initial reaction, I haven't studied the code in more
detail.

/Simon

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
(Continue reading)

Steffen Lehmann | 12 Jan 2011 10:08
Picon

Re: POP3 Authorization using SCRAM-SHA-1 fails

Martin Lambers <marlam <at> marlam.de> writes:

> Would you please test it?

Hi Martin,

I will test it as soon as a new version is ready for download.

Steffen

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
Martin Lambers | 12 Jan 2011 17:42
Picon

Re: POP3 Authorization using SCRAM-SHA-1 fails

On 12/01/11 10:08, Steffen Lehmann wrote:
>> Would you please test it?
> 
> I will test it as soon as a new version is ready for download.

OK, I made an intermediate release available at
<http://www.marlam.de/mpop-1.0.22a.tar.bz2>.

Martin

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
Steffen Lehmann | 14 Jan 2011 10:09
Picon

Re: POP3 Authorization using SCRAM-SHA-1 fails

Martin Lambers <marlam <at> marlam.de> writes:

> 
> On 12/01/11 10:08, Steffen Lehmann wrote:
> >> Would you please test it?
> > 
> > I will test it as soon as a new version is ready for download.
> 
> OK, I made an intermediate release available at
> <http://www.marlam.de/mpop-1.0.22a.tar.bz2>.
> 
> Martin
> 

Congratulations, mpop's SCRAM-SHA-1 authentication works fine now.

Steffen

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
Martin Lambers | 15 Jan 2011 13:18
Picon

Re: POP3 Authorization using SCRAM-SHA-1 fails

Hi Simon!

On 11/01/11 22:36, Simon Josefsson wrote:
>> >From your analysis, it seems that SCRAM-SHA-1 needs the same exception
>> rule that DIGEST-MD5 needs, so the attached patch might fix the problem.
>> Would you please test it?
> ...
>> -    /* For DIGEST-MD5, we need to send an empty answer to the last 334
>> -     * response before we get 235. */
>> -    if (strcmp(auth_mech, "DIGEST-MD5") == 0)
>> +    /* For DIGEST-MD5 and SCRAM-SHA-1, we need to send an empty answer to the
>> +     * last response before we get an OK. */
>> +    if (strcmp(auth_mech, "DIGEST-MD5") == 0
>> +            || strcmp(auth_mech, "SCRAM-SHA-1") == 0)
> 
> This looks a bit strange -- it shouldn't special-case SASL mechanisms,
> but just use the normal SASL state machine.  You can use the return
> value from gsasl_step function to guide you when to quit the loop,
> although you need to observe that each challenge has a response.

I have no idea how to get this working for all mechanisms without
special handling of some. The loop currently is this:

do {
    e = gsasl_step64(ctx, in, &out);
    if (e != OK && e != NEEDS_MORE) {
        /* fail */;
    }
    if (!in) {
        /* send AUTH <MECHANISM> */
(Continue reading)

Martin Lambers | 17 Jan 2011 21:47
Picon

mpop 1.0.23 is released.

Hi all,

mpop 1.0.23 is released.

This release fixes SCRAM-SHA-1 authentication via GNU SASL.

Martin

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl

Gmane