Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Qmail: users

Bug in many patches (incl. John Simpson's) to qmail-remote to handle SMTP AUTH

 

 

Qmail users RSS feed   Index | Next | Previous | View Threaded


tomas.juqutuseveh.lee.796265 at gmail

Jan 21, 2010, 9:08 PM

Post #1 of 6 (1668 views)
Permalink
Bug in many patches (incl. John Simpson's) to qmail-remote to handle SMTP AUTH

Many months ago, I tried to report a minor bug in John Simpson's
qmail-combined-patch. I tried subscribing to the mailing list,
but I never got my subscription approved, and I tried writing him
directly, but I never heard anything. So I gave up.

But today I see that he does read this mailing list, so I thought I
would try reporting it here. The bug exists in many patches anyway, not
just his qmail-combined-patch, so it's not completely off-topic for this
list.

This bug is in the patch to qmail-remote so it can use SMTP AUTH with
remote servers.

After authenticating to a remote smtp server, the client is supposed
to send an additional AUTH= parameter to the MAIL FROM command. This
is documented in RFC 2554.

Unfortunately, the patch handles this additional paramter wrong. It
puts angle brackets ("<", ">") around the value. It's not supposed to do
that. It also neglects to encode the value in an xtext. It is supposed
to do that. (See RFC 1891 for information on xtext encoding of MAIL
parameters.)

I think that it is a rare server that actually uses the AUTH
parameter. In the majority of cases, the only thing that's done is to
check it for syntactic validity. (I am thinking particularly of the
case where the qmail server is connecting to an ISP's SMTP server that
requires authentication.) So in most cases, no one will notice this
bug. The incorrect value of the AUTH= parameter just gets ignored --
the client may as well have used the special "AUTH=<>" parameter.

But, if the authentication ID contains an equal sign (=), and it is
not xtext encoded, then qmail-remote will send a syntactically invalid
MAIL FROM command, and the message will probably get rejected. That's
how I ran into this bug.

This bug is in a lot of patches. John Simpson's qmail-combined-patch
inherited it from Tom Clegg's qmail-remote-auth.patch. Tom Clegg got it
from Jay Soffian's qmail-remote_authenticated_smtp.patch. Jay Soffin's
patch is included in a number of combined patches, including Andrew St.
Jean's qregex-starttls-2way-auth.patch, which is used in Gentoo's qmail
the last time I checked. I'm sure it's in more patches -- these are
just the ones I've personally seen it in.

I don't actually think that this E-mail is going to cause all of these
patches to be fixed. I'm mainly interested in having John Simpson
update his qmail-combined-patch because he seems to be actively
maintaining his patch and because I use his patch. If he fixes it,
that's one less thing for me to do when I install qmail on a system.

Interestingly enough, John Simpson in his patch has almost entirely
replaced Tom Clegg's work with Erwin Hoffmann's AUTH patches, but he
seems to have missed this xtext fix. On his details page, he writes

This patch [Version 6ca] incorporates all of his [Hoffman's]
fixes, so the AUTH code in my combined patch is equivalent to his
qmail-authentication-0.6.4 patch (which is current as of
2006-12-15, when I'm writing this.)

I just checked qmail-authentication-0.6.4 as well as
qmail-authentication-0.6.8 (which is now the current version), and both
patches handle the xtext encoding correctly.


jms1 at jms1

Jan 22, 2010, 10:57 AM

Post #2 of 6 (1607 views)
Permalink
Re: Bug in many patches (incl. John Simpson's) to qmail-remote to handle SMTP AUTH [In reply to]

On 2010-01-22, at 0008, Tomas Lee wrote:
>
> Many months ago, I tried to report a minor bug in John Simpson's
> qmail-combined-patch. I tried subscribing to the mailing list,
> but I never got my subscription approved, and I tried writing him
> directly, but I never heard anything. So I gave up.

"many months ago", meaning four days ago?

i manually approve all of the subscription requests, because spammers sometimes try to subscribe to the list. and to be honest, your email address looks like a random collection of words and numbers that a spammer would come up with, so i ignored it, thinking you were a spammer. this is the first time i'm aware of being wrong about guessing which addresses were spammers, you have my apologies for ignoring you.

now that i see you're a human being (and not a spammer, at least i hope not) i've just approved your subscription request. however i'm not sure ezmlm-idx will still consider it a valid request, i think it times them out after 72 hours. if not, let me know and i'll add you by hand.

with that said...

i will admit it's been a while since i looked at that part of the code, so i'm not as intimately familiar with it as i am with most of the patches affecting qmail-smtpd. i'd rather have somebody who's more familiar with that part of the code look at the issue first, and see if they can fix it. if so, then obviously i'll incorporate their fix into my combined patch.

and if nobody else wants to look at it (or has the time) then i guess i can take a look, although any fixes i release will probably be specific to my patch, and people who use other patches will have to manually undo bits of my stuff and massage it into whatever patch they're using. i'd rather see the problem fixed in the "upstream" patches, than having to force others to have to figure out how to take a patch i wrote and figure out how to make it work with whatever patches they're using.

i'll wait and see what others have to say before i start trying to dig into the code myself.

----------------------------------------------------------------
| John M. Simpson --- KG4ZOW --- Programmer At Large |
| http://www.jms1.net/ <jms1 [at] jms1> |
----------------------------------------------------------------
| http://video.google.com/videoplay?docid=-1656880303867390173 |
----------------------------------------------------------------
Attachments: PGP.sig (0.19 KB)


root at letinet

Jan 22, 2010, 11:12 AM

Post #3 of 6 (1613 views)
Permalink
Re: Bug in many patches (incl. John Simpson's) to qmail-remote to handle SMTP AUTH [In reply to]

Tomas Lee wrote:

> This bug is in the patch to qmail-remote so it can use SMTP AUTH with
> remote servers.
>
> After authenticating to a remote smtp server, the client is supposed
> to send an additional AUTH= parameter to the MAIL FROM command. This
> is documented in RFC 2554.

Hello Tomas!
Three years ago, I've faced with this trouble when trying
to authenticate with Lotus server. You can find my post
in this list
http://www.gossamer-threads.com/lists/qmail/users/132418?search_string=smtp%20auth;#132418

I've just commented two lines in patched code and all went fine.

--
Best, Roman


tomas.juqutuseveh.lee.796265 at gmail

Jan 25, 2010, 2:07 AM

Post #4 of 6 (1550 views)
Permalink
re: Bug in many patches (incl. John Simpson's) to qmail-remote to handle SMTP AUTH [In reply to]

On Jan 22, 2010, John Simpson <jms1 [at] jms1> wrote:
> On 2010-01-22, at 0008, Tomas Lee wrote:
>>
>> Many months ago, I tried to report a minor bug in John Simpson's
>> qmail-combined-patch. I tried subscribing to the mailing list,
>> but I never got my subscription approved, and I tried writing him
>> directly, but I never heard anything. So I gave up.
>
> "many months ago", meaning four days ago?

No, meaning "many months ago." August 19, to be precise. The
subscription request I sent on January 18 was not my first attempt. I
was first affected by this bug in the summer, and I recorded the bug and
my in my notes and tried to send a report upstream. I then forget about
it until I had occassion to install qmail on another system. When I
consulted my notes, I was reminded of this bug and decided to try to
report it again. It was just a coincidence that I saw your message to
the qmail mailing list (to which I was already subscribed) at this time.

> i manually approve all of the subscription requests, because spammers
> sometimes try to subscribe to the list. and to be honest, your email address
> looks like a random collection of words and numbers that a spammer would
> come up with, so i ignored it, thinking you were a spammer. this is the
> first time i'm aware of being wrong about guessing which addresses were
> spammers, you have my apologies for ignoring you.

That's OK. Don't worry about it. I hope I didn't sound like I'm
bearing a grudge or anything. I'm just a guy who keeps a log of all the
non-spam mail I send or receive. I'd actually forgotten about it until
I re-read my notes.

> now that i see you're a human being (and not a spammer, at least i hope not)
> i've just approved your subscription request. however i'm not sure ezmlm-idx
> will still consider it a valid request, i think it times them out after 72
> hours. if not, let me know and i'll add you by hand.

Yes, I've been subscribed.

> with that said...
>
> i will admit it's been a while since i looked at that part of the code, so
> i'm not as intimately familiar with it as i am with most of the patches
> affecting qmail-smtpd. i'd rather have somebody who's more familiar with
> that part of the code look at the issue first, and see if they can fix it.
> if so, then obviously i'll incorporate their fix into my combined patch.
>
> and if nobody else wants to look at it (or has the time) then i guess i can
> take a look, although any fixes i release will probably be specific to my
> patch, and people who use other patches will have to manually undo bits of
> my stuff and massage it into whatever patch they're using. i'd rather see
> the problem fixed in the "upstream" patches, than having to force others to
> have to figure out how to take a patch i wrote and figure out how to make it
> work with whatever patches they're using.
>
> i'll wait and see what others have to say before i start trying to dig into
> the code myself.

There is an upstream patch which xtext encodes the AUTH= parameter:
Erwin Hoffmann's AUTH patches, available at
<http://www.fehcom.de/qmail/auth/qmail-authentication-068_tgz.bin>,
linked from <http://www.fehcom.de/qmail/smtpauth.html>. But I gather
that, even though "the AUTH code in [your] combined patch is equivalent
to his qmail-authentication-0.6.4 patch" (with the exception of the
xtext encoding), that patch wouldn't actually apply cleanly to your
patch. So I understand why you'd want to wait and see what others have
to say.

Incidentally, you've already made changes in this area from the original
patch you used: you changed that AUTH= parameter from the envelope
sender to the authenticated user name. (I believe this is the correct
thing to do.)

The patch I used is pretty simple:



--- qmail-remote.c-the-old-source 2009-07-17 23:05:58.000000000 -0700
+++ qmail-remote.c 2009-07-17 23:03:53.000000000 -0700
@@ -531,9 +531,7 @@
if (authd) {
substdio_puts(&smtpto,"MAIL FROM:<");
substdio_put(&smtpto,sender.s,sender.len);
- substdio_puts(&smtpto,"> AUTH=<");
- substdio_put(&smtpto,auth_smtp_user.s,auth_smtp_user.len);
- substdio_puts(&smtpto,">\r\n");
+ substdio_puts(&smtpto,"> AUTH=<>\r\n");
substdio_flush(&smtpto);
} else {
substdio_puts(&smtpto,"MAIL FROM:<");



This has the advantage of being easy to understand, conforming to RFC
2554 (in fact, it's explicitly specified as conforming behavior), and
working for my particular situation. But I don't know enough to say
that this is the best thing to do for a widely distributed patch such as
yours. Some people who know more than I in this area (e.g., Erwin
Hoffman) encode other information in this paramter, and I can't argue
with them.

To be more generally correct, I would have had to copy the xtext
encoding function from qmail-authentication-068_tgz.bin (about two dozen
lines of code.)

Hmm... Now that I'm looking at qmail-authentication-068_tgz.bin, the
xtext encoding function doesn't look completely correct either. I had
tested it before, but I only looked to make sure it was syntactially
correct (i.e., no unencoded "=" or "+" signs). I didn't check to see if
it decoded to the same value. But maybe I'm just thinking that because
it's late. I'll see if I can find time later to set up scratch
installation and test this.


jms1 at jms1

Feb 5, 2010, 8:39 AM

Post #5 of 6 (1358 views)
Permalink
Re: Bug in many patches (incl. John Simpson's) to qmail-remote to handle SMTP AUTH [In reply to]

On 2010-01-25, at 0507, Tomas Lee wrote:
>
> There is an upstream patch which xtext encodes the AUTH= parameter:
> Erwin Hoffmann's AUTH patches, available at
> <http://www.fehcom.de/qmail/auth/qmail-authentication-068_tgz.bin>,
> linked from <http://www.fehcom.de/qmail/smtpauth.html>. But I gather
> that, even though "the AUTH code in [your] combined patch is equivalent
> to his qmail-authentication-0.6.4 patch" (with the exception of the
> xtext encoding), that patch wouldn't actually apply cleanly to your
> patch. So I understand why you'd want to wait and see what others have
> to say.

i thought it was a clean copy... i missed the xtext stuff entirely.

now i've stolen the xtext() function from his patch, added it to my combined patch, and now the AUTH= parameter should be xtext-encoded. however, i don't have any machines which need this functionality, so i haven't tested it as well as i probably should. if you get a chance to test it, let me know how it works.


> Incidentally, you've already made changes in this area from the original
> patch you used: you changed that AUTH= parameter from the envelope
> sender to the authenticated user name. (I believe this is the correct
> thing to do.)

yup. i also added some code so that if AUTH LOGIN fails, it will try AUTH PLAIN before giving up.


> The patch I used is pretty simple:
>
> --- qmail-remote.c-the-old-source 2009-07-17 23:05:58.000000000 -0700
> +++ qmail-remote.c 2009-07-17 23:03:53.000000000 -0700
> @@ -531,9 +531,7 @@
> if (authd) {
> substdio_puts(&smtpto,"MAIL FROM:<");
> substdio_put(&smtpto,sender.s,sender.len);
> - substdio_puts(&smtpto,"> AUTH=<");
> - substdio_put(&smtpto,auth_smtp_user.s,auth_smtp_user.len);
> - substdio_puts(&smtpto,">\r\n");
> + substdio_puts(&smtpto,"> AUTH=<>\r\n");
> substdio_flush(&smtpto);
> } else {
> substdio_puts(&smtpto,"MAIL FROM:<");

i went ahead and made it do the xtext encoding. if i'm gonna do it, may as well do it right.


> This has the advantage of being easy to understand, conforming to RFC
> 2554 (in fact, it's explicitly specified as conforming behavior), and
> working for my particular situation. But I don't know enough to say
> that this is the best thing to do for a widely distributed patch such as
> yours. Some people who know more than I in this area (e.g., Erwin
> Hoffman) encode other information in this paramter, and I can't argue
> with them.

i'm using the xtext-encoded represenation of the SMTP AUTH user. i think that makes the most sense, and i'm pretty sure that's what the RFC says is supposed to be there.


> Hmm... Now that I'm looking at qmail-authentication-068_tgz.bin, the
> xtext encoding function doesn't look completely correct either. I had
> tested it before, but I only looked to make sure it was syntactially
> correct (i.e., no unencoded "=" or "+" signs). I didn't check to see if
> it decoded to the same value. But maybe I'm just thinking that because
> it's late. I'll see if I can find time later to set up scratch
> installation and test this.

i did copy mine from the 069 version, so it should be correct (i saw your other message about the "=" and "+" encodings being switched around.)

thanks for letting me (and everybody else, i guess) know about this.

----------------------------------------------------------------
| John M. Simpson --- KG4ZOW --- Programmer At Large |
| http://www.jms1.net/ <jms1 [at] jms1> |
----------------------------------------------------------------
| http://video.google.com/videoplay?docid=-1656880303867390173 |
----------------------------------------------------------------
Attachments: PGP.sig (0.19 KB)


tomas.juqutuseveh.lee.796265 at gmail

Feb 22, 2010, 4:49 PM

Post #6 of 6 (1153 views)
Permalink
Re: Bug in many patches (incl. John Simpson's) to qmail-remote to handle SMTP AUTH [In reply to]

On 2010-02-05, John Simpson <jms1 [at] jms1> wrote:
> On 2010-01-25, at 0507, Tomas Lee wrote:
>>
>> There is an upstream patch which xtext encodes the AUTH= parameter:
>> Erwin Hoffmann's AUTH patches, available at
>> <http://www.fehcom.de/qmail/auth/qmail-authentication-068_tgz.bin>,
>> linked from <http://www.fehcom.de/qmail/smtpauth.html>. But I gather
>> that, even though "the AUTH code in [your] combined patch is equivalent
>> to his qmail-authentication-0.6.4 patch" (with the exception of the
>> xtext encoding), that patch wouldn't actually apply cleanly to your
>> patch. So I understand why you'd want to wait and see what others have
>> to say.
>
> i thought it was a clean copy... i missed the xtext stuff entirely.
>
> now i've stolen the xtext() function from his patch, added it to my combined
> patch, and now the AUTH= parameter should be xtext-encoded. however, i don't
> have any machines which need this functionality, so i haven't tested it as
> well as i probably should. if you get a chance to test it, let me know how
> it works.

Thanks! I just checked out version 7.10 of your patch. The xtext
changes work for me. That is, qmail-remote is able to autheticate
itself and send out mail through my designated MSA. The caveat is that
my situation only requires the AUTH= parameter to be syntactically
valid, and nothing actually checks to see if the value was xtext encoded
correctly. But, when I eyeballed my logs, the xtext encoding looked
correct to me.

Thanks again!

Qmail users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.