Skip to contentSkip to conversation

How to handle tmpfiles under /home ?

DISCUSSION Thomas Bleher 3 participants 4 messages Jun 7, 2004 – Jun 9, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

I recently ran into a problem with tmpfiles in my homedir. I have configured mutt to store mails I write under ~/.mutt/tmp/. Unfortunately, current policy only allows postfix to read user_tmp_t. This leads to postfix sending totally empty mails in enforcing mode.

Now the question is how to best handle this situation? (I believe this is more common than just mail as it is generally encouraged to change $TMP to something not world writable)
First I thought about adding the permissions to all programs accessing user tmpfiles, but this would practically remove the distinction between user_home_t and user_tmp_t.

My next thought was to label say ~/.tmp/ as user_tmp_t and point $TMP there. Unfortunately there is no standard directory across distros for this.
Ideally this should be configurable by the user, but I'm not sure if it's worth the trouble.

As I am not sure what the best thing to do is both practically and from a security POV I am posting this here.

Thoughts?

Thomas

Signature · 2 lines
http://www.cip.ifi.lmu.de/~bleher/selinux/ - my SELinux pages
GPG-Fingerprint: BC4F BB16 30D6 F253 E3EA  D09E C562 2BAE B2F4 ABE7
#1 lore raw
Quoted 4 lines · Thomas Bleher

I recently ran into a problem with tmpfiles in my homedir. I have configured mutt to store mails I write under ~/.mutt/tmp/. Unfortunately, current policy only allows postfix to read user_tmp_t. This leads to postfix sending totally empty mails in enforcing mode.

<snip>

Quoted 8 lines

My next thought was to label say ~/.tmp/ as user_tmp_t and point $TMP there. Unfortunately there is no standard directory across distros for this.
Ideally this should be configurable by the user, but I'm not sure if it's worth the trouble.

As I am not sure what the best thing to do is both practically and from a security POV I am posting this here.

Better to put the mail client into its own domain (which is also a good idea for confining flawed mail clients), and define its own derived type for files it creates.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
In reply to Thomas Bleher
Quoted 4 lines · Thomas Bleher

I recently ran into a problem with tmpfiles in my homedir. I have configured mutt to store mails I write under ~/.mutt/tmp/. Unfortunately, current policy only allows postfix to read user_tmp_t. This leads to postfix sending totally empty mails in enforcing mode.

What version of the policy allows postfix to access user_tmp_t?

user_mail_t is allowed access to files of type user_tmp_t. But apart from that there should be no access of postfix to user_tmp_t.

user_tmp_t generally should not be used for files under the user home directory, so ~/.mutt/tmp should be labelled as user_home_t.

If you create a file on /tmp and mv it to ~ then if ~ and /tmp are on the same file system then it will get the type user_tmp_t, is this the case with mutt? What does that have to do with Postfix anyway? Postfix should not be attempting delivery to ~/.mutt anyway.

Your message didn't clarify what your problem is, or what your objectives are, so I can't give any advice until I get more information.

As for Steve's message about putting the MUA into it's own domain, the problem with that is that the MUA is usually expected to be able to attach files from any directory and save received attachments to any directory. It wants to run gpg and store the gpg pass-phrase, so unless the usage patterns are significantly changed there's little ability to lock things down.

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
Quoted 11 lines · Russell Coker
Quoted 4 lines · Thomas Bleher

I recently ran into a problem with tmpfiles in my homedir. I have configured mutt to store mails I write under ~/.mutt/tmp/. Unfortunately, current policy only allows postfix to read user_tmp_t. This leads to postfix sending totally empty mails in enforcing mode.

What version of the policy allows postfix to access user_tmp_t?

user_mail_t is allowed access to files of type user_tmp_t. But apart from that there should be no access of postfix to user_tmp_t.

Yeah, I was unclear here. The denial occurs in user_mail_t.

Quoted 10 lines

user_tmp_t generally should not be used for files under the user home directory, so ~/.mutt/tmp should be labelled as user_home_t.

If you create a file on /tmp and mv it to ~ then if ~ and /tmp are on the same file system then it will get the type user_tmp_t, is this the case with mutt? What does that have to do with Postfix anyway? Postfix should not be attempting delivery to ~/.mutt anyway.

Your message didn't clarify what your problem is, or what your objectives are, so I can't give any advice until I get more information.

Apparently my mail wasn't clear so I'll try to restate my problem:
I'm using mutt to read mail over IMAP, sent mail goes through a local postfix. mutt can be configured where to store mails which are being composed. I chose ~/.mutt/tmp which means that newly created messages have type user_home_t. mutt then calls /usr/sbin/sendmail which transitions to user_mail_t. sendmail wants to read the new message, fails to do so because it isn't allowed to read user_home_t; as a result a totally empty message is sent.

I have fixed this particular case in my local policy already but I posted it here because I think that this is a more general problem:
I think it is generally encouraged for users to set $TMP and $TMPDIR to some directory which is under their control and not world-writable. This can be done under /tmp (I think Bastille-Linux had a script for this) but it is much easier for users to do this in their homedir. The problem however is that setting $TMP to something under ~ breaks with current policy.
This is OK on systems with only a few users who can easily be educated but presents problems on systems with a few thousand users. So my hope is that there will be some generic solution (like ~/.tmp) as I still see some security benefits to private homedirs, even with SELinux.

Quoted 6 lines

As for Steve's message about putting the MUA into it's own domain, the problem with that is that the MUA is usually expected to be able to attach files from any directory and save received attachments to any directory. It wants to run gpg and store the gpg pass-phrase, so unless the usage patterns are significantly changed there's little ability to lock things down.

I agree with this. Additionally I'm reading mail over imap, so my mail reader needs network access.

Thomas

Signature · 2 lines
http://www.cip.ifi.lmu.de/~bleher/selinux/ - my SELinux pages
GPG-Fingerprint: BC4F BB16 30D6 F253 E3EA  D09E C562 2BAE B2F4 ABE7