Received: from termpaper.tycho.ncsc.mil (termpaper [144.51.3.7]) by tycho.ncsc.mil (8.9.3/8.9.3) with SMTP id QAA24097 for ; Tue, 22 May 2001 16:26:37 -0400 (EDT) Date: Tue, 22 May 2001 16:56:16 -0400 (EDT) From: edm@tycho.ncsc.mil Subject: Re: Immunity against Buffer Overflows / exploits To: selinux@tycho.nsa.gov Message-Id: <1010522165616.216AAH0F.edm@termpaper> In-Reply-To: Mime-Version: 1.0 (Generated by Eloquent) Content-Type: text/plain; charset=US-ASCII Sender: owner-selinux@tycho.nsa.gov List-Id: selinux@tycho.nsa.gov Actually, selinux provides a very effective defense against the exploitation of buffer overflows. Here's why: A typical use of the buffer overflow attack is for the attacker to execute a shell or some other program (such as a compiler as the internet virus did.) Under selinux, only certain domains are allowed to execute a shell or another program for that matter. If the policy does not allow the domain that the program is executing in to exec a shell or another process (or fork for that matter), a policy violation occurs and the attack is stopped. In addition, even if the process can execute another program only programs that have the proper type allowed by the policy can be executed within a particular domain. These restrictions apply to "privileged" (or root) processes as well. Root under selinux is not like root under linux, it's restricted. All system processes are each setup to execute in their own domain. These domains have only the privileges that are necessary for its process to execute. For example, if fingerd is attacked using buffer overflow, the policy will prevent it from executing another program. In addition, even if that attacker is able to inject extensive code into the process space, that code will only be able to access those objects that the policy restricts the fingerd's domain to. However, if the policy allows for that domain type to access /dev/mem (or any file that allows access to system memory) then the system can be attack. It is important to note, however, that the policy has to allow for a given domain type to access this and any domain that needs this type of access needs review. -->Under selinux only programs that execute in the klogd and the xserver domains have this access.<-- gene >> > Hello there, >> > >> > I just wondered, whether the security mechanisms implemented in SELinux >> > would be able to protect the system from the exploit (not the occurrence) >> > of Buffer Overflows. >> >> Simple answer: No. >> >> > Let's assume, the security mechanism and the kernel are sane & safe. An >> > application runs in "underpriviledged" mode, that is the policy permits >> > the application to read file A and read & write to file B. Now, if the >> > application tries to go berserk, the policy control mechanism will take it >> > out and shoot it. But if somehow a buffer within the application gets an >> > overflow, will it be able to acces memory areas, that belong to other >> > applications? >> >> The buffer overlow will only access current process memory. If that >> process can attach to other memory (via /proc or /dev/kmem) then >> anything goes. > >I'm not sure, if I fully got that. So, basically, the application >has only it's _own_ memory for data and it's own instruction stack, is >that correct? And, as long as the policy is intact, whatever will happen >in this overwritten buffer will not be able to do anything that the >application was not allowed to. Of course, if the application was allowed >to mess with memory directly, we will be in deep trouble. But even >standard linux should be able to keep userprocesses from doing so. >(I tried on this machine to mess with /proc and /dev/kmem as a user, no >way. Admittedly, I did it in a very dilletant way with cat /dev/kmem ) > >> The problem is significant, but no solution currently exists. >> >> Depends on hardware support - >> IF the hardware allows read/write access to memory and denies >> execute access to read/write memory (instruction space is execute >> only) THEN and only then can buffer overflows be properly limited. >> >> You still have the problem of causing an "exec" to another program. But >> that is (partially) a different problem. This can be addressed. >> >> If an executable image on disk is not permitted to "fork/exec/..." then >> it can be prevented. That is one of the advantages to static linking >> over using shared libraries. The static link will only have the system >> calls included that it requires. If the program doesn't use fork/exec >> system call, then it would not be included. >> >> If this is combined with hardware protection above, then the exec system >> call could not be invoked. >> >> Invoking the system call currently can be done by loading the system call >> invokation on the stack, with parameters and the pointer to the stack area >> containing this executable code (replacing the return address of the caller; >> then allowing the current function to complete. >> >> If the stack cannot be exected it fails. >> >> If the return address on the stack points to an exec function, then the >> exec will be executed, using the other parameters on the stack (loaded via >> the overflow). >> >> If the exec function doesn't exist in the text image then it fails. >> >> If the privileges of the process doesn't include exec, then it would >> also fail, even if the exec system call were included. >> >> This combined with the non-executable rw memory (stack and data) then >> a reasonable amount can be done to shield against buffer overflows. >> >> Unfortuanately, protection of rw memory is not available on Intel. >> A: If you can read it, it is executable. >> B: If you can write it; you can read it. (see A) >> >> Other patforms may vary. > >So I see, the question is now, to which extend security can be done in >software and where do we have to fondle with hardware. > >Thanks you, > >JanP > > >-- >You have received this message because you are subscribed to the selinux list. >If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with >the words "unsubscribe selinux" without quotes as the message. -- You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with the words "unsubscribe selinux" without quotes as the message.