packet/socket owner match (fireflier) using skfilter
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · Török Edwin
Fireflier aims at providing per application filtering. That is allowing to create rules like: allow apache to listen on port 80 (and only apache, nobody else).
I had a very simple idea for doing something like this:
Assign a special semantic to GID $n: Being in group $n allows you to listen on port $n-$offset. $offset == -1 disables this feature (default).
E.g. You want apache to listen on 80 and 443: Set $offset to 60000 and put apache into groups 60080 and 60443.
Quoted 3 lines
I didn't include the patch inline, since it is quite long (1800+ lines , ~100k). So I uploaded them here:
http://edwintorok.googlepages.com/fireflier_kernel.html
(Text in parentheses written after completely reading the posting)
If I'd want it to work with iptables, I'd extend the socket struct to contain the device:inode of the corresponding application (not changing it on exec) and stat() the allowed applications on rule setups.
(I see you choose similar but more complicated approach, but:)
I'd deliberately allow access to these sockets if it's passed to other applications since it's the intended behaviour. (BTW: Your approach isn't going to be 100 % reliable, since it will allow other processes to illegaly receive data if the socket is transfered after filtering, isn't it?)
Downside of both approaches:
You'll have to guarantee stable dev:inode pairs. NFS? umount/mount?
Workaround: suid helper setting/deleting the allowed-rule?
Signature · 2 lines
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF verbreiteten Lügen zu sabotieren.
Quoted 1 line
I had a very simple idea for doing something like this:
Your idea is interesting. Unfortunately it is not directly applicable, and is more a "hack", than a solution.
Quoted 4 lines
Assign a special semantic to GID $n: Being in group $n allows you to listen
on port $n-$offset. $offset == -1 disables this feature (default).
Modifying gids is not a good idea, the sysadmin might need it for other purposes.
Quoted 4 lines
If I'd want it to work with iptables, I'd extend the socket struct to contain
the device:inode of the corresponding application (not changing it on exec)
and that would require recompiling the kernel
Quoted 4 lines
and
stat()the allowed applications on rule setups.I'd deliberately allow access to these sockets if it's passed to other applications since it's the intended behaviour.
It might be intended behaviour, or it might be a file descriptor leak. If I have a rule in iptables saying to allow only apache (just an example) access to port 80, I don't want any other program to have access to it. If apache might leak a file descriptor (it doesn't, just an example), and give access to other programs, the firewall would restrict those programs. If I would implicitly trust them, then fireflier rules wouldn't be any better, than just creating rules to allow any program to listen on port 80.
Quoted 4 lines
(BTW: Your approach isn't
going to be 100 % reliable, since it will allow other processes to illegaly
receive data if the socket is transfered after filtering, isn't it?)
filtering is done on each packet, how could the socket be transfered between the time the packet is filtered, and the time it is received by the program?
A socket transfer can be done via execve, or IPC, both covered (I hope) by the fireflier lsm.
Quoted 3 lines
Downside of both approaches:
You'll have to guarantee stable dev:inode pairs.
This could be ensured from userspace, if it becomes an issue.
Quoted 1 line
NFS?
running a program via NFS, and giving access for it to the network? why would I want that?
Anyway, if somebody wants that, we could determine the inode of the program on nfs mount time. We could store the path+hash of the program to be sure it is the same program.
Quoted 1 line
umount/mount?
Aren't inodes stored on the disk?
Quoted 1 line
Workaround: suid helper setting/deleting the allowed-rule?
No need for suid though, fireflier-server runs as root.
Quoted 1 line
Cheers,
Edwin
Quoted 11 lines · On Fri, 7 Apr 2006 [email protected] wrote:
Quoted 2 lines
I'd deliberately allow access to these sockets if it's passed to other applications since it's the intended behaviour.
It might be intended behaviour, or it might be a file descriptor leak. If I have a rule in iptables saying to allow only apache (just an example) access to port 80, I don't want any other program to have access to it. If apache might leak a file descriptor (it doesn't, just an example), and give access to other programs, the firewall would restrict those programs. If I would implicitly trust them, then fireflier rules wouldn't be any better, than just creating rules to allow any program to listen on port 80.
If apache is running a CGI script, it must pass the socket (bound to remote:port,local:80, to the CGI at fd 2*. If your firewall is blocking this, your CGI scripts will stop working.
* unless it intends to proxy the connection
Quoted 10 lines
Quoted 4 lines
(BTW: Your approach isn't
going to be 100 % reliable, since it will allow other processes to illegaly
receive data if the socket is transfered after filtering, isn't it?)filtering is done on each packet, how could the socket be transfered between the time the packet is filtered, and the time it is received by the program?
A socket transfer can be done via execve, or IPC, both covered (I hope) by the fireflier lsm.Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Downside of both approaches:
You'll have to guarantee stable dev:inode pairs.This could be ensured from userspace, if it becomes an issue.
Quoted 1 line
NFS?
running a program via NFS, and giving access for it to the network? why would I want that?
Why not? E.g. you could set up a farm of redundand apache servers.
Quoted 6 lines
Anyway, if somebody wants that, we could determine the inode of the program on nfs mount time. We could store the path+hash of the program to be sure it is the same program.
Quoted 1 line
umount/mount?
Aren't inodes stored on the disk?
At least Mostly, but is this a requirement?
Signature · 2 lines
Fun things to slip into your budget True and it was approved: 128 MBytes of VIRTUAL memory.
Quoted 5 lines · Bodo Eggert
On Fri, 7 Apr 2006 [email protected] wrote:
If apache is running a CGI script, it must pass the socket (bound to remote:port,local:80, to the CGI at fd 2*. If your firewall is blocking this, your CGI scripts will stop working.
Hmm, an exception could be made for programs like apache.
The user would then create a rule that says that apache is allowed to pass on
file descriptors.
Or a rule could be created for the userspace part of fireflier that would auto-add the cgi-scripts to apache's group sid. Which IMHO would be the best, because the user will still have control on what programs have access to the network. He can see that list at any time, and modify it, if not correct. If we would simply allow file descriptors to be passed on, he wouldn't have that control. (none of this is implemented yet)
Quoted 4 lines
Quoted 2 lines
running a program via NFS, and giving access for it to the network? why would I want that?
Why not? E.g. you could set up a farm of redundand apache servers.
Ok, so the userspace part of fireflier will have to deal with nfs mounts as a special case. It should store the rules in "server,path,executable hash" format, and do the inode lookup on startup, or when the first packet arrives.
Quoted 3 lines
Quoted 1 line
Aren't inodes stored on the disk?
At least Mostly, but is this a requirement?
Currently it is, until we implement path+hash rules for nfs mounts,etc. What devices can I safely assume that the inodes won't change over boots/mounts?
Cheers,
Edwin