CVE-2014-9273 (published 2014-12-08T16:59Z)

lib/handle.c in Hivex before 1.3.11 allows local users to execute arbitrary code and gain privileges via a small hive files, which triggers an out-of-bounds read or write.

Severity: MEDIUM
CVSS v2 base score: 4.6 (AV:L/AC:L/Au:N/C:P/I:P/A:P)

Weakness information:
cwe_id: CWE-119
cwe_name: Improper Restriction of Operations within the Bounds of a Memory Buffer
description: The product performs operations on a memory buffer, but it reads from or writes to a memory location outside the buffer's intended boundary. This may result in read or write operations on unexpected memory locations that could be linked to other variables, data structures, or internal program data.
extended_description: 
            Certain languages allow direct addressing of memory locations and do not automatically ensure that these locations are valid for the memory buffer that is being referenced. This can cause read or write operations to be performed on memory locations that may be associated with other variables, data structures, or internal program data.
         
         

Fix information:
repo_url: https://github.com/libguestfs/hivex
commit_details: repo_url: https://github.com/libguestfs/hivex
author: Richard W.M. Jones
author_date: 2014-10-30 14:02:25+00:00
msg: handle: Check that pages do not extend beyond the end of the file.

Thanks: Mahmoud Al-Qudsi
repository: repo_url: https://github.com/libguestfs/hivex
repo_name: libguestfs/hivex
description: windows registry hive extraction library.  PLEASE DO NOT USE GITHUB FOR ISSUES OR PULL REQUESTS. See the website for how to file a bug or contact us.  http://libguestfs.org
repo_language: C
owner: libguestfs
file_changes: filename: handle.c
change_type: ModificationType.MODIFY
diff: @@ -247,6 +247,13 @@ hivex_open (const char *filename, int flags)
       goto error;
     }
 
+    if (off + page_size > h->size) {
+      SET_ERRNO (ENOTSUP,
+                 "%s: page size %zu at 0x%zx extends beyond end of file, bad registry",
+                 filename, page_size, off);
+      goto error;
+    }
+
     /* Read the blocks in this page. */
     size_t blkoff;
     struct ntreg_hbin_block *block;

programming_language: C
repo_url: https://github.com/libguestfs/hivex
commit_details: repo_url: https://github.com/libguestfs/hivex
author: Richard W.M. Jones
author_date: 2014-10-30 13:50:39+00:00
msg: handle: Refuse to open files < 8192 bytes in size.

These cannot be valid hives, since they don't contain a full header
page and at least a single page of data (in other words they couldn't
contain a root node).

Thanks: Mahmoud Al-Qudsi
repository: repo_url: https://github.com/libguestfs/hivex
repo_name: libguestfs/hivex
description: windows registry hive extraction library.  PLEASE DO NOT USE GITHUB FOR ISSUES OR PULL REQUESTS. See the website for how to file a bug or contact us.  http://libguestfs.org
repo_language: C
owner: libguestfs
file_changes: filename: handle.c
change_type: ModificationType.MODIFY
diff: @@ -104,6 +104,13 @@ hivex_open (const char *filename, int flags)
 
   h->size = statbuf.st_size;
 
+  if (h->size < 0x2000) {
+    SET_ERRNO (EINVAL,
+               "%s: file is too small to be a Windows NT Registry hive file",
+               filename);
+    goto error;
+  }
+
   if (!h->writable) {
     h->addr = mmap (NULL, h->size, PROT_READ, MAP_SHARED, h->fd, 0);
     if (h->addr == MAP_FAILED)

programming_language: C