Re: Re: request: qmail-qfilter to use mkdtemp()

Bruce Guenter <[email protected]> Thu, 26 Oct 2017 12:19:23 -0600
Newsgroups gmane.comp.sysutils.bgware
Message-ID <[email protected]>
--kUBUi7JBpjcBtem/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Oct 26, 2017 at 01:59:33AM -0400, Amitai Schleier wrote:
> On 25 Oct 2017, at 19:19, Bruce Guenter wrote:
>=20
> > On Tue, Oct 24, 2017 at 02:51:10PM -0400, Amitai Schleier wrote:
> >> This works beautifully -- iff I chmod qmail-qfilter's TMPDIR wide open,
> >> which is obviously terrible.
> >
> > Why is it obviously terrible? qmail-qfilter uses mkstemp to create
> > temporary file names, which is designed to do so securely. In fact, the
> > default for qmail-qfilter is to create its temporary files in /tmp,
> > which is generally world writeable.
>=20
> That makes sense. Maybe I've long misunderstood this part of the README:
>=20
> > - Check the definitions at the top of qmail-qfilter.c, especially the
> >   value of TMPDIR.  This should be set to a temporary directory that
> >   only the executor of qmail-qfilter has write access to.
>=20
> As a packager of qmail-qfilter, I've always taken this to mean I ought to=
 create a subdirectory like /tmp/qmail-qfilter, owned by qmaild:root, mode =
700-ish.

That would be the ideal, and it eliminates the possibility of bugs in
mkstemp allowing for symlink attacks or whatever. However, assuming your
mkstemp implementation is secure, it will work with a world writeable
/tmp. The wording doesn't make that subtlety clear.

> If you've been thinking about a new release at some point, there is still=
 one tiny patch I'd love to see integrated. It exports qmail-qfilter's pare=
nt's PID to the environment, so filters can log the PID of the (e.g.) qmail=
-smtpd session that invoked them: https://github.com/bruceg/qmail-qfilter/p=
ull/1/commits/b7acc42a19b4f66a29e9faa0b0c52dd44e64a7bf Needs to be added to=
 the man page as well (sorry, just noticed the omission).

I am open to this, yes. Please add the man page change and I'll pull it.

--=20
Bruce Guenter <[email protected]>                http://untroubled.org/

--kUBUi7JBpjcBtem/
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature

-----BEGIN PGP SIGNATURE-----

iQIyBAEBCAAdFiEEQJAAJIYhxdYHEgzqUVG9ycFNPGcFAlnyJysACgkQUVG9ycFN
PGeJlQ/2JnPvKn6QxB7E5Z+omi/ut4Nw/kV74SEwKw60xqNS0zzv9rYumE63TCsW
qT94hF3/mN5Liv81IYDOroL5g2+ONH6U1eLSeW8go5ttTwKdXM0YySQ7rvmTLDiH
oEPTtvbCDAwl/vbCu+QS0LH0mpnsg0IMQZb6GvXmatfIjq9zWEcRd9Agnb+anaw+
zCoi7+leN4R2rB42K7q5+B303rW+SenMn2GOkm67fZRoBzBqRi/QigffEjBr6Kp+
Yfeg8qGyUvyhlaf+AsD6CwMkXiJWgB1m1MptzfxToMKi0ZYlUfWFXEL7FLDXOBHs
KMLAWUNGvIPBnJlje+7f72kb8jm+3deU4V08BfdqegsVtgkqmUDbzIeeWMxIaE7q
LK3ozNLQ9pV8HUDTrkDTPJDn4Vo1RSBgGuA8+8biD7jXh6mq0WBLtktzvgl+rych
VhWBJ1n4SrLxNwSvzKYpCPiwbKAJ7WA5pUmKHe+30N6rotPAu60oeuKBkegs7996
2dMCm9YbJFfQTHLu+G+WuCmqlzH5E+f2PB0NPwn3895D0h2klgixoAhU0Qv7Mqrp
rpADuAxitocaHFa6f6kqURRpPTgXpjeEaFAA+D1qHRiid18/tKfI0uUyXwgPmaPL
P3wJnvwKRrp/emFmFA/V71oW6S+so/o7+mfm9F0EH7bidXWUmg==
=VIuy
-----END PGP SIGNATURE-----

--kUBUi7JBpjcBtem/--