IV International Conference of Unix at Uninet
  • Presentation
  • Register
  • Program
  • Organizing Comittee
  • Listing of registered people
  • Translators team
Talk

20031216.1.en.log

rielok, I guess it's time to start this afternoon's talk
rielI have set the channel to moderated, so only ops can talk now
rielif you have questions or want to chat about the presentation, you can do so in #qc
rielI think there will also be a spanish translation in #redes
rielfor the people who prefer the talk in spanish
rielthis afternoon, my friend and colleague James Morris will talk about the interesting (but rather complex) subject of SELinux networking
rielthere are a lot of aspects involved with this, so I won't confuse you by talking about a wrong one in my introduction ;)
rielJames Morris has been a linux kernel developer for quite a while
rielhe is a member of the netfilter core team
rieland is now paid by Red Hat to work on selinux things
rielI hope this talk will touch on both sides of James his Linux experience
rielnow I'll sit back to enjoy the talk
jamesmWelcome everyone :-)
jamesmThis talk will be about networking under SELinux, but first I will provide a brief introduction to SELinux itself.
jamesmIt provides Linux with Mandatory Access Control (MAC) security.
jamesmSELinux will be part of the 2.6 kernel.
jamesmStandard Unix/Linux has Discretionary Access Control (DAC), where
jamesmmost security decisions are made at the user's discretion.
jamesmFor example,
jamesmif a user wants to share a file, they can just type chmod 644 file to
jamesmmake it readable by others.
jamesmUnder a MAC system, the kernel will actually decide whether the file
jamesmcan be shared, instead of the user.
jamesmA security policy will be used
jamesmto specify the security rules for the system.
jamesmSELinux uses a generalized security model, where kernel objects
jamesm(e.g. processes, files) are each labeled with a security context.
jamesmA security context can contain a number of security attributes for
jamesmthe object.
jamesme.g. the role is an attribute, and could be sysadmin
jamesmWhen a security decision has to be made, SELinux
jamesmlooks at the security contexts of each object and then consults
jamesmthe security policy to determine whether access is granted.
jamesm For
jamesmexample, only a process labeled with a sysadmin role might be
jamesmallowed to access the /etc/shadow.
jamesmHopefully this has introduced two important ideas in SELinux:  Mandatory Access Control, and Security Contexts
jamesmThis is a very simplified overview.  More information on SELinux can
jamesmbe found at http://www.nsa.gov/selinux/docs.html
jamesmAlso, a really good introductory article is at
jamesmhttp://sourceforge.net/docman/display_doc.php?docid=15285&group_id=21266
jamesmby Faye Coker.
jamesmSELinux extends MAC security to networking.
jamesmThis is important and useful because of the number of systems that are now networked.
jamesmSELinux allows networked machines to be hardened against many types of vulnerabilities and user errors.
jamesmFirstly, all socket system calls are covered by SELinux.
jamesme.g. a process
jamesmmust have permission to use socket(), bind(), listen(), accept(),
jamesmsendmsg(), recvmsg() etc.
jamesmThis effectively allows SELinux to control
jamesmwhich applications can do networking.
jamesmIf you can't use the socket system calls, you will have problems doing any networking.
jamesmSome of these permissions are further broken down by protocol: TCP, UDP
jamesmand Raw IP.
jamesmSo, for example, SELinux is able to
jamesmimpose a policy where a certain application, such as Apache, can only
jamesmperform socket calls for TCP.
jamesmIf Apache was compromised, the kernel
jamesmwould not allow Apache to work with UDP sockets.
jamesmFurther permissions are provided for bind(), where the port number
jamesmcan be specified (e.g. only listen on port 80), as well as which local
jamesmIP addresses may be used.
jamesm(note that no changes need to be made to applications for this, it is all controlled via security policy and enforced at the kernel level)
jamesmPermissions are also provided which allow policy to specify which
jamesmnetwork interfaces traffic can be sent or received over.
jamesmhis is
jamesmalso applied on a per protocol basis.
jamesmFor example, you may write
jamesma policy which says that Apache can only send and and receive TCP
jamesmtraffic over eth1.
jamesmNetwork traffic can also be controlled by IP address for a given
jamesmprocess and protocol.
jamesmCombining these controls together provides a powerful and flexible
jamesmway to contain network facing applications.
jamesmPutting it all together, a simple example would be to specify
jamesmthat sshd is allowed to use the socket system calls for TCP,
jamesmbind to port 22, send and receive TCP traffic over an internal
jamesminterface to intranet addresses only.
jamesmApplications such as ssh, sshd, bind etc. can all be locked down in a similar way.
jamesmOne question that you might be asking is how is this different to iptables?
jamesmFirstly, the network traffic is associated with specific processes (this can only be done in a very limited way under iptables as it is only present at the network layer)
jamesmThe SELinux controls are part of a much larger scheme where the applications are also constrained from what they can do e.g. on the local filesytem.
jamesmNurbs asks:  can one filter based on SE roles and such with netfilter/iptables (in addition to what is given by the SE linux configuration already)?
jamesmyes, you could write an iptables match for the security context, but it would only work for outgoing packets generated locally
jamesmfor incoming packets, the iptables hook at the network layer cannot know how the packet is eventually associated with userspace (if at all)
jamesmriel asks: are there plans to transport the security context across the network (with ipsec), so you can filter incoming packets based on security context too ?
jamesmyes, I will cover that soon
jamesmWhat we have with SELinux networking currently is a way to harden systems against attacks (internal as well as external), and configuration errors, integrated with a comprehensive MAC system.
jamesmMany (if not most) of the vulnerabilities seen recently would have been contained by SELinux, although it cannot protect against kernel bugs (e.g. the do_brk() vulnerability) or poorly implemented policy.
jamesmSo it is not a magic bullet.
jamesmSELinux is still under development (work on features is expected
jamesmto continue after the 2.6.0 kernel is released)
jamesmaalih asks:  what's the overhead associated with all the SE's check?
jamesmso far, from my own measurements, between 5-15% depending on what you are testing
jamesmas more networking features are implemented, networking will get slower
jamesmhowever, some major work on performance and scalability improvments will take place within the next 6 months
jamesmfor example, there is one lock which seems to account for half of the performance hit: that is something which should be fixable
jamesmbut there will always be some overhead
jamesmhanna asks: what lock is that?
jamesmit is the avc_lock in avc_has_perm(), which is taken for every single access permission check
jamesmthis looks like a candidate for RCU (read copy update)
jamesmfeistel asks: differences between openbsd's systrace and selinux?
jamesmI'm not very familiar with systrace, although it looks like it provides control over how applications use syscalls
jamesmSELinux can control the use of syscalls, as part of an integrated security policy
jamesmSome of the networking features planned for SELinux include:
jamesm- Add controls for send/receive traffic by port.  (I'm working on this today :-)
jamesm- Enhance local Unix sockets so that applications can authenticate
jamesm  each other using SELinux security credentials.
jamesm(this is implemented, and under review by other developers)
jamesmThe Unix socket enhancement will be useful for integrating SELinux into X and for local IPC such as DBUS.
jamesmbut they are major topics themselves.
jamesm- Making the network controls more expressive (they are powerful,
jamesm  but not as easy to use as e.g. iptables rules).
jamesm- Labeled networking (this extends the security model over the
jamesm  network).
jamesm- Better NFS support.
jamesm- IPSec integration (e.g. security policy may specify protection
jamesm  requirements for network traffic).
jamesmriel asked before about transporting the security contexts over the network.
jamesmThis is called labeled networking.
jamesmTypically, each packet has a label attached (in SELinux, a security context).
jamesmOr multiple labels (e.g. one indicating the security context of the sending process, one indicating the context of the message, and possibly one requesting that the destination process have a certain security context)
jamesmThis was implemented using IP options in an earlier version of SELinux, although it has been dropped, as the LSM hooks needed to support it were not accepted in the mainline kernel.
jamesmAn even earlier version was implemented before SELinux, using the predecessor Flask architecture.
jamesmBut instead of labeling each packet, IPSec connections were labeled
jamesmso, each packet flowing over a given IPSec connection (more technically, each security association) had an implicit label.
jamesmThe security labeling was negotiated via an extension to ISAKMP (the key management protocol).
jamesmFuture packet labeling may revert to the IPSec based method.
jamesmLabeled networking would probably only be useful in very high security environments where systems are under tight administrative control (e.g. telecomms)
jamesmsydb asks: Why were the LSM hooks not included in mainline kernel (or were they just silently dropped?) Does IPSec method have big disadvantages?
jamesmthe LSM hooks for labeled networking were rejected by the maintainer as they were too invasive
jamesmthey were basically poking around inside network protocols
jamesmwe have been able to implement almost everything using other means (e.g. via Netfilter), so the decision looks to be sound so far :-)
jamesmthe IPSec method has two disadvantages (in my view).
jamesm1) It makes IPSec more complicated, which is bad for security.
jamesm2) It combines labeling and protection into the same mechanism
jamesmthis means that if you want labeling, you must have ipsec
jamesmthis is probably what most people actually want though
jamesm(but some environments may do encryption on the wire, for example)
jamesmoverall though, after looking at both schemes, the IPsec system has some nice simplicity in that you just have to look at the SA (security association) that the packet belongs to, rather than parse IP options
jamesmand IP options probably don't work on the real internet as many firewalls/routers will block them
jamesmcdub asks: on inbound packets (say tcp accept) it's possible more than one process (or no process) is waiting for syn.  because processing happens in interrupt context, do you ever have problems with getting proper context to compare?
jamesmyes, there are a couple of cases which we need to look at now that there are no hooks in the TCP code
jamesmthis may be solvable by doing a lookup, but needs more investigation
jamesmok, I have finished the material I planned to present, are there any more questions?
jamesmcdub asks: i've had troubles with processes which can change security context getting data they sholdn't have access to
jamesmin SELinux or just with LSM?
jamesmfor SELinux, you can only change security context on exec, so perhaps you are inheriting the socket?
jamesmriel asks:  how is ipsec & selinux going to benefit normal system administrators, who can't set up complex security rules themselves ?
jamesmgood question
jamesmfirstly, for ipsec, it should be possible to simplify configuration for common uses, e.g. VPNs
jamesmI think that is managable, e.g. IPSec is in wide use today
jamesmfor SELinux, it will be more difficult I think
jamesmhopefully distributions will provide good policies for applications which normally don't need to be changed
jamesmand common policy updates like adding users etc. will be wrapped in user friendly applications
jamesmbut I think that this is really the big unknown for SELinux
jamesmand a very big challeng for Red Hat, Debian, Gentoo etc.
jamesmchallenge
jamesmany more questions?
jamesmnurbs asks: what do you mean by better NFS support?
jamesmthis can mean simply preserving the file security contexts over NFS, or more complicated, having the NFS server impose security policy on the remote filesystem as if it was local
jamesmthis needs to be implemented using extensions to NFSv2/3
jamesmNFSv4 has more scope for this (e.g. you need Extended Attributes to be sent over the wire: these are how SELinux security contexts are implemented for files)
jamesmbut work needs to be done to both NFS and SELinux for this to work well
jamesmthe current NFS support is minimal: an nfs mounted filesystem appears locally with all files and directories having the same security context, and no security contexts are stored remotely
jamesmok, it looks like I am finished now :-)<riel> thank you James !
rielclap clap clap clap clap
MJesusclap clap clap clap clap clap clap clap clap clap
EMPE[log]plas plas plas plas plas
rielclap clap clap clap clap
MJesusclap clap clap clap clap clap clap clap clap clap
MJesusclap clap clap clap clap clap clap clap clap clap

Generated by irclog2html.pl by Jeff Waugh - find it at freshmeat.net!

email usmore information


© 2003 - www.uninet.edu - contact organizing comittee - valid xhtml - valid css - design by raul pérez justicia