VirtualBox is a general-purpose full virtualizer for x86 hardware,
targeted at server, desktop and embedded use.

VirtualBox provides -among many other features- 3D Acceleration for
guest machines
through its Guest Additions. This feature allows guest machines to use
the host machine's
GPU to render 3D graphics based on then OpenGL or Direct3D APIs.

Multiple memory corruption vulnerabilities have been found in the code
that implements
3D Acceleration for OpenGL graphics in Oracle VirtualBox.
These vulnerabilities could allow an attacker who is already running
code within
a Guest OS to escape from the virtual machine and execute arbitrary code
on the Host OS.

4. *Vulnerable packages*

. Oracle VirtualBox v4.2.20 and earlier.
. Oracle VirtualBox v4.3.6 and earlier.
. Other versions may be affected too but they were no checked.

5. *Non-vulnerable packages*

. Oracle VirtualBox v4.3.8.

6. *Credits*

This vulnerability was discovered and researched by Francisco Falcon from
Core Exploit Writers Team. The publication of this advisory was coordinated
by Andres Blanco from Core Advisories Team.

7. *Technical Description / Proof of Concept Code*

VirtualBox makes use of the *Chromium*[1] open-source library
(not to be confused with the open-source web browser) in order to
provide 3D Acceleration for OpenGL graphics.

Chromium provides remote rendering of OpenGL graphics through a
client/server model, in which
a client (i.e. an OpenGL application) delegates the rendering to the
server, which has access
to 3D-capable hardware.

When 3D Acceleration is enabled in VirtualBox, OpenGL apps running
within a Guest OS
(acting as Chromium clients) will send rendering commands to the
Chromium server, which is
running in the context of the hypervisor in the Host OS.

The code that handles OpenGL rendering commands on the Host side is
prone to multiple memory
corruption vulnerabilities, as described below.

7.1. *VirtualBox crNetRecvReadback Memory Corruption Vulnerability*

[CVE-2014-0981] The first vulnerability is caused by a *design flaw* in
Chromium. The Chromium server makes use
of "*network pointers*". As defined in Chromium's documentation,
'"Network pointers are
simply memory addresses that reside on another machine.[...] The
networking layer will then
take care of writing the payload data to the specified address."'[2]

So the Chromium's server code, which runs in the context of the
VirtualBox hypervisor
in the Host OS, provides a write-what-where memory corruption primitive
*by design*, which
can be exploited to corrupt arbitrary memory addresses with arbitrary
data in the hypervisor process
from within a virtual machine.

This is the code of the vulnerable function [file
'src/VBox/GuestHost/OpenGL/util/net.c'], which can
be reached by sending a 'CR_MESSAGE_READBACK' message to the
'VBoxSharedCrOpenGL' service:

/-----
/**
* Called by the main receive function when we get a CR_MESSAGE_READBACK
* message. Used to implement glGet*() functions.
*/
static void
crNetRecvReadback( CRMessageReadback *rb, unsigned int len )
{
/* minus the header, the destination pointer,
* *and* the implicit writeback pointer at the head. */

Note that 'rb' points to a 'CRMessageReadback' structure, which is fully
controlled by the
application running inside a VM that is sending OpenGL rendering
commands to the Host side.
The 'len' parameter is also fully controlled from the Guest side, so
it's possible to:

1. decrement the value stored at any memory address within the
address space of the hypervisor.
2. write any data to any memory address within the address space of
the hypervisor.

7.2. *VirtualBox crNetRecvWriteback Memory Corruption Vulnerability*

[CVE-2014-0982] The second vulnerability is closely related to the first
one, and it's also caused by Chromium's
"*network pointers*".

This is the code of the vulnerable function [file
'src/VBox/GuestHost/OpenGL/util/net.c'], which can
be reached by sending a 'CR_MESSAGE_WRITEBACK' message to the
'VBoxSharedCrOpenGL' service:

Note that 'rb' points to a 'CRMessageWriteback' structure, which is
fully controlled by the
application running inside a VM that is sending OpenGL rendering
commands to the Host side, so it's possible to
decrement the value stored at any memory address within the address
space of the hypervisor.

[CVE-2014-0983] When an OpenGL application running inside a VM sends
rendering commands (in the form of opcodes + data for those opcodes)
through
a 'CR_MESSAGE_OPCODES' message, the Chromium server will handle them in
the 'crUnpack' function.
The code for the 'crUnpack' function is automatically generated by the
Python script located
at 'src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py'.

This function is basically a big switch statement dispatching different
functions according to the opcode being processed:

'VertexAttrib4NubARB' is a function pointer in a dispatch table, and
points to the function
'crServerDispatchVertexAttrib4NubARB', whose code is generated by the
Python script located at
'src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py':

Note that the 'index' parameter, which is a 4-byte integer coming from
an untrusted source (the opcode data
sent by the Chromium client from the VM), is used as an index within the
'cr_server.current.c.vertexAttrib.ub4'
array in order to write 'cr_unpackData' (which is a pointer to the
attacker-controlled opcode data), without
validating that the index is within the bounds of the array.
This issue can be leveraged to corrupt arbitrary memory with a pointer
to attacker-controlled data.

Also note that *the same vulnerability affects several functions* whose
code is generated by the
'src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py'
Python script:

CoreLabs, the research center of Core Security Technologies, is charged
with anticipating
the future needs and requirements for information security technologies.
We conduct our research in several important areas of computer security
including system vulnerabilities, cyber attack planning and simulation,
source code auditing, and cryptography. Our results include problem
formalization, identification of vulnerabilities, novel solutions and
prototypes for new technologies. CoreLabs regularly publishes security
advisories, technical papers, project information and shared software
tools for public use at:
http://corelabs.coresecurity.com.

11. *About Core Security Technologies*

Core Security Technologies enables organizations to get ahead of threats
with security test and measurement solutions that continuously identify
and demonstrate real-world exposures to their most critical assets. Our
customers can gain real visibility into their security standing, real
validation of their security controls, and real metrics to more
effectively secure their organizations.

Core Security's software solutions build on over a decade of trusted
research and leading-edge threat expertise from the company's Security
Consulting Services, CoreLabs and Engineering groups. Core Security
Technologies can be reached at +1 (617) 399-6980 or on the Web at:
http://www.coresecurity.com.

This advisory has been signed with the GPG key of Core Security
Technologies advisories
team, which is available for download at
http://www.coresecurity.com/files/attachments/core_security_advisories.a
sc.