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

Mailing List Archive: exim: users

Alternative to the -D option

 

 

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


russell-exim at stuart

Oct 9, 2011, 11:39 PM

Post #1 of 6 (594 views)
Permalink
Alternative to the -D option

I am upgrading my configuration from a much older version of exim, and
now I get this message in my paniclog:

2011-10-10 11:10:07 exim user lost privilege for using -D option

I used the -D option to tell exim to deliver large messages. Delivery
of large messages is disabled normally. Instead cron regularly starts a
background instance of exim running as root with a special -D option
that causes it to skip the large message check. The net effect of this
is to ensure there is at most one instance exim clogging up my link with
the delivery of outbound videos and what not.

I gather from the exim's man page that -D option is now frowned upon.
In fact if I read it correctly it doesn't work at all unless I do a
custom compile setting WHITELIST_D_MACROS. So what is preferred
mechanism for giving exim information? Is there another command line
switch, or is there some way to extract it from the environment?


--
Regards,
Russell Stuart


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


pdp at exim

Oct 10, 2011, 12:08 AM

Post #2 of 6 (590 views)
Permalink
Re: Alternative to the -D option [In reply to]

On 2011-10-10 at 16:39 +1000, Russell Stuart wrote:
> I gather from the exim's man page that -D option is now frowned upon.
> In fact if I read it correctly it doesn't work at all unless I do a
> custom compile setting WHITELIST_D_MACROS. So what is preferred
> mechanism for giving exim information? Is there another command line
> switch, or is there some way to extract it from the environment?

Build Exim with TRUSTED_CONFIG_LIST defined; that points to a file
listing the paths of defined-by-admin-to-be-safe config files.

Use another config file which sets a couple of macros and then
.include's the real config file, and then reference this new config file
in the trusted list.

That way, the precise set of available macros is locked down to files
controlled/owned by root, or the configure owner (which should _not_
include the Exim run-time user).

Sorry, the old freedom made it far too easy to escalate privileges from
the Exim run-time user to root (unless you built Exim as setuid to a
dedicated user instead of root, per some of the pointers in "52.
Security considerations").

-Phil


russell-exim at stuart

Oct 10, 2011, 3:51 AM

Post #3 of 6 (591 views)
Permalink
Re: Alternative to the -D option [In reply to]

Thanks for the very fast response.

On Mon, 2011-10-10 at 03:08 -0400, Phil Pennock wrote:
> Use another config file which sets a couple of macros and then
> .include's the real config file, and then reference this new config file
> in the trusted list.

This is what I ended up doing.

> That way, the precise set of available macros is locked down to files
> controlled/owned by root, or the configure owner (which should _not_
> include the Exim run-time user).

As I discovered it isn't an ideal alternative. I lied. I had two
independent variables. On coming to the realisation using this method
to set N independent variables would need N! (N factorial) config files,
I decided it was time to eliminate one.

> Sorry, the old freedom made it far too easy to escalate privileges from
> the Exim run-time user to root (unless you built Exim as setuid to a
> dedicated user instead of root, per some of the pointers in "52.
> Security considerations").

Yes, well the old -D was a disaster waiting to happen, but you need a
replacement. There are lots of reasons people want tell exim to use
their config files in some special mode. My large message queues was
one. Sadly I passed in the message size with -DMAX_MESSAGE_SIZE=size.
It was a handy option but it had to go for now. I had another queue for
dealing with low priority messages which came into being when a massive
virus attack meant real messages weren't getting though. I haven't used
it in a while so it went as well. Others use macro's to feed messages
back into exim after some special processing has been done (eg spam,
virus checking). I now realise the WHITELISTED_D_MACROS thing was a
debian hack introduced for this reason.

I guess you are aware of this.


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


jgh at wizmail

Oct 10, 2011, 5:07 AM

Post #4 of 6 (583 views)
Permalink
Re: Alternative to the -D option [In reply to]

On 10/10/2011 11:51, Russell Stuart wrote:
> Others use macro's to feed messages
> back into exim after some special processing has been done (eg spam,
> virus checking).

I used a "protocol" name for this purpose.
--
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


pdp at exim

Oct 10, 2011, 2:13 PM

Post #5 of 6 (584 views)
Permalink
Re: Alternative to the -D option [In reply to]

On 2011-10-10 at 20:51 +1000, Russell Stuart wrote:
> virus checking). I now realise the WHITELISTED_D_MACROS thing was a
> debian hack introduced for this reason.

No, it was a "Phil Pennock hack", introduced because I insisted that
people were using macros in sane ways and, by very carefully limiting
the character set allowed to appear in a macro, we could limit the
damage and provide people time to migrate carefully instead of having to
slash & burn.

I'm a sysadmin, I like migration strategies other than "redo all your
configs at upgrade time, only ever roll forward". I like giving others
that freedom too. :)

Rather than throw away a lot of work right now in a hurry, I suggest
building Exim using the whitelist for the macros you have, and work with
us on exim-users to try to find ways to deal with the remaining issues.
Some of those ways might involve code changes for new facilities.

Someone's already suggested using a "protocol" to deal with some
problems. That's the -oMr flag.

There's a proposal/patch which adds a ${getenv:...} expansion operator
(or somesuch). That would not propagate cleanly to messages delivered
by queue-runners started from another context, but might be useful in
some conditions. Would it help with some of your current issues? I'm
mostly in favour of adding ${getenv:...}. It does have some security
impact, but the _results_ of getenv are not subject to string expansion,
as macro results are (unless fed back through ${expand:...}) so is
generally much MUCH safer.

And so on. You're using Exim responsibly in a production environment
and we want to help you to continue to do so without having to cripple
anything or remove emergency recovery methods which experience has shown
you to be necessary. _Changing_ the recovery method may be necessary,
but removing a recovery method is just asking for trouble.

-Phil

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


russell-exim at stuart

Oct 10, 2011, 6:20 PM

Post #6 of 6 (585 views)
Permalink
Re: Alternative to the -D option [In reply to]

On Mon, 2011-10-10 at 17:13 -0400, Phil Pennock wrote:
> Someone's already suggested using a "protocol" to deal with some
> problems. That's the -oMr flag.

I used -oMt in a similar manner. But ick.

> There's a proposal/patch which adds a ${getenv:...} expansion operator
> (or somesuch). That would not propagate cleanly to messages delivered
> by queue-runners started from another context, but might be useful in
> some conditions. Would it help with some of your current issues? I'm
> mostly in favour of adding ${getenv:...}. It does have some security
> impact, but the _results_ of getenv are not subject to string expansion,
> as macro results are (unless fed back through ${expand:...}) so is
> generally much MUCH safer.

I did have a couple of options in my previous email, but I deleted them
when I thought about exim's internal architecture. The problem is
complex and there are several ways of addressing it. I doubted I could
tell you guys who deal with it all the time anything new. But since you
asked ...

The perfect solution to all of my uses would be to only allow -D to be
set by trusted users (eg root). As the author of the exim.conf file
this means I don't have check the value of such settings. I can assume
they make sense because the came from a trusted source. But this is
obvious, and if it was easy it would have been done.

From my knowledge of exim's architecture it spawns many sub-processes
and the difficulty is in communicating to those non-privileged
sub-processes that the -D was by someone you can trust. Maybe there is
some trick you can use, like creating a temporary read only file owned
the trusted user, unlink'ing it immediately, writing the trusted
settings to it, and passing the handle to the sub-process. The
sub-process can use fstat to verify the file was created a trusted
process. There is nothing much new in the process, as exim already
create lots of files with settings (eg acl's) it must trust in its spool
directories, so it is unlikely to create a security hole. There are no
messy cleanup issues - as the OS will clean up when the last handle
disappears. It's so transient I doubt the data will hit the disk.

The other option I though of was along the lines of what you suggest
with getenv. Again, it's an obvious thing to do, so obvious in fact
that that I went searching the spec for it as a work around. My guess
was it wasn't there because it wasn't portable to some platform. So
instead of that, since the -D option is going the way of the dodo,
instead I would just change the way it works. Provide a ${dopt{name}}
that returns the VALUE in -Dname=VALUE. Then migrating would just be a
case of "sed -i 's/\<name\>/${dopt{name}}/g' exim.conf".

As you noted, something that allows a non-privileged user to inject
random values does seem like a bit of a loophole, and since I don't need
to do that I personally prefer the "allow trusted users to set -D"
option. However, I can well imagine someone out there will have some
perfectly good reason for needing a normal user to pass information in.
In my case, since I write my own config, I doubt it would create a real
loophole, as I have security through obscurity. No one is even going to
know the names of the macros I use. If there is an issue, it will be
for well know configs like those packages with the distro's.

You could do both I guess. Ie have a ${dopt{name}} and
${dopt_unsafe{name}}, the first only returning macros set by trusted
users. The ability to do this is one advantage of something like
${dopt{...}} over ${getenv:...}.



--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

exim 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.