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

pine-cert-20040201.txt

pine-cert-20040201.txt
Posted Feb 4, 2004
Authored by Joost Pol | Site pine.nl

Pine Digital Security Advisory PINE-CERT-20040201 - The shmat(2) function has a flaw that allows local users to achieve escalated privileges. Vulnerable systems: FreeBSD versions 2.2.0 and greater, NetBSD versions 1.3 and greater, and OpenBSD versions 2.6 and greater.

tags | advisory, local
systems | netbsd, freebsd, openbsd
SHA-256 | a574248c2ca40bfc4b92b9ac9a645d17d7ca2b2477dbce0dd28b3dd3e9b6ce84

pine-cert-20040201.txt

Change Mirror Download
-------------------------------------------------------------------------------
Pine Digital Security Advisory
-------------------------------------------------------------------------------
Advisory ID : PINE-CERT-20040201 (CAN-2004-0114)
Authors : Joost Pol
Vendor Informed : 2004-02-01
Issue date : 2004-02-05
Application : kernel / sysv shared memory
Platforms : FreeBSD, NetBSD and OpenBSD
Availability : http://www.pine.nl/press/pine-cert-20040201.txt
-------------------------------------------------------------------------------

Synopsis

While gathering material for a security training Pine
Digital Security encountered a reference count overflow
condition which could lead to privilege escalation.

Versions

Vulnerable versions include:

FreeBSD >= 2.2.0, NetBSD >= 1.3 and OpenBSD >= 2.6

Impact

Serious.

Local users can elevate their privileges.

Description

The shmat(2) function maps a shared memory segment, previously
created with the shmget(2) function, into the address space of
the calling process.

This function is implemented in the sysv_shm.c file:

-- sysv_shm.c lines 317-322 --


vm_object_reference(shm_handle->shm_object);

rv = vm_map_find(&p->p_vmspace->vm_map,
shm_handle->shm_object,
0, &attach_va, size,
(flags & MAP_FIXED) ? 0 : 1,
prot, prot, 0);

if (rv != KERN_SUCCESS) return ENOMEM;


-- end of code snippet --

The shmat(2) function first increases the reference count on
the underlying vm_object and then attempts to insert the
vm_object into the process address space.

The vulnerability occurs because the shmat(2) function forgets
to decrease the reference count when the vm_map_find function
returns failure.

Since the caller of shmat(2) can specify the address at which
the segment should be mapped it is possible to have vm_map_find
return failure and thus end up with stale references.

Exploitability

This vulnerability can exploited (reliably) by local users:

One would first create a shared memory segment using the shmget(2)
function and create two seperate mappings at different locations
in the process address space using the shmat(2) function.

After making around 2^32-2 (invalid) calls to the shmat(2)
function the reference count of the underlying vm_object
will wraparound to 1.

After deleting one of our mappings using the shmdt(2) function
the underlying vm_object will be freed and we will still have
one (extranous) mapping hanging around.

One would then invoke some magic trickery and execute a suid
binary which will reuse the freed vm_object for its stack
segment.

At this point one could write directly into the stack segment
of the suid binary (using the extranous mapping) and thus
escalate ones privileges easily.

Disclaimer

Pine Digital Security does not release exploits.

Patches

The various CVS repositories should be updated.

References

FreeBSD-SA-04:02.shmat.asc

http://www.pine.nl/press/pine-cert-20040201.txt

http://cve.mitre.org/cgi-bin/cvename.cgi?name=can-2004-0114

file://usr/src/sys/kern/sysv_shm.c
file://usr/src/sys/vm/vm_object.c
file://usr/src/sys/vm/vm_map.c
Login or Register to add favorites

File Archive:

September 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close