qmail Author Considered Dangerous
Thanks to LWN I was reminded of the, erm, interesting license and security guarantee of qmail. Specifically:
In March 1997, I offered $500 to the first person to publish a verifiable security hole in the latest version of qmail: for example, a way for a user to exploit qmail to take over another account. My offer still stands. Nobody has found any security holes in qmail. [...] In May 2005, Georgi Guninski claimed that some potential 64-bit portability problems allowed a ``remote exploit in qmail-smtpd.'' This claim is denied. Nobody gives gigabytes of memory to each qmail-smtpd process, so there is no problem with qmail's assumption that allocated array lengths fit comfortably into 32 bits.
Erm. Well. I'm not sure what to say. Assuming that array lengths (size_t, IIRC) is a 32-bit type even on 64-bit architectures is wrong. Defending it is insanity.
NP: Layered, Antibreak
Bernsteing said that well administered smtp process have resource limit so they never reach 1Gb of data segment, even on a 64bit architecture. (there is no use to handle 1Gb emails).
Also, I may have some insane plan that involves sending 1GB emails: say I work in the movie industry. I'd prefer to use a MTA that either sent it fine or refused to send it as it's too large, not one that crashed unless I set a separate set of resource limits.
From the web page I link to: "The stralloc concept and getln() make it very easy to avoid buffer overruns, memory leaks, and artificial line length limits.". This appears to be failing if a large email can crash qmail.
djb's larger point is that it's not safe to assume that your programs will catch every resource exhaustion attack, thus every long-running process should run under resource limits imposed by the kernel.
- free software developer offers $$$ if you find a bug
- person finds a bug
- developer refuses to acknowledge it to save $$$
What if I found an exploit if you sent a particular byte? Would the response be "well, any sane sysadmin would install a packet filter to ...".
This seems like an isolated incident, but if it becomes common, at some point, a sane sysadmin will just switch to a MTA maintained by somebody who doesn't make excuses.
The question here is that someone found some parts of the code that may have problems in 64 bit systems, as some arrays use only the 32 first part in his code.
On one hand it's true that if the size of the variable is 64 bit, it should be treated as 64 bits, no 32.
On the other hand the Qmail's author offered $500 to the first person who find an explotable bug. That remains to be seen if it's exploitable or not. Probably you won't be able to fill the 32 bit arrays before crushing the mailer first under the load.
I don't like Qmail for its strange behaviors and particular way of doing all things. But his DNS tools are the best, tinydns and the like. Really good and nice to configure/mantain.
"That remains to be seen if it's exploitable or not."
Guninski provided an exploit. Nothing left to be seen.
The fact remains that IF you install qmail as per the documentation (granted, you have to read it very closely indeed), this hole is not exploitable. I would agree that the software should be fixed for aesthetics alone, but this is not what the security guarantee covers.
To be vulnerable, you would have to both compile it in a 64-bit environment AND avoid setting any size limitations.
If you configure your software to receieve 8 GB (!) emails, you're probably vulnerable to DoS attacks even when you've patched this hole.
In a years time the majority of servers will be 64-bit, so your "to be vulnerable" statement comes down to "don't set size limitations". At the end of the day the bug is, as far as I know, "assume array lenghts are 32-bit", which is wrong. Very wrong. There is no way that is correct on a 64-bit machine. Fixing this would involve changing an "int" to a "long", or using the correct type, "size_t". This is a BUG. No matter how great the rest of qmail is, or how great his other software is, assuming array lengths are 32-bit is BROKEN. Refusing to acknowledge this by saying that you should have limitations preventing large emails isn't helpful.