< Return to Video

36C3 - The Great Escape of ESXi

  • 0:00 - 0:19
    36c3 preroll
  • 0:19 - 0:25
    Herald: So like many operators, in my
    group, we actually use a lot of ESXi
  • 0:25 - 0:28
    servers. You would think that after using
    these things for 10 years, I would know
  • 0:28 - 0:35
    how to speak, but I do not. We use these
    for virtualizing machines. Some of... some of
  • 0:35 - 0:40
    these actually runs on sandboxes or, you
    know, run kind of dubious software on it.
  • 0:40 - 0:46
    So we really do want to prevent these
    processes from jumping from the virtual
  • 0:46 - 0:54
    environment to the hypervisor environment.
    We have today - we have - f1yyy, he wants
  • 0:54 - 1:03
    to be known by f1yyy, so I'm respecting
    that; and he's from Triton Security Labs,
  • 1:03 - 1:10
    and he's going to show us how the exploits
    that he discovered in the, I think it was
  • 1:10 - 1:15
    the last Chinese GeekPwn capture the flag.
    He's gonna show us how these things work,
  • 1:15 - 1:22
    and was that I would like to help. I would
    like to ask you, to help me, welcome f1yyy
  • 1:22 - 1:24
    onto the stage.
  • 1:24 - 1:29
    applause
  • 1:29 - 1:42
    f1yyy: Hello. Thanks for the introduction.
    Good evening, everybody. I'm f1yyy a
  • 1:42 - 1:49
    Senior Security Researcher at Chaitin
    Technology. I'm going to present The Great
  • 1:49 - 1:57
    Escape of ESXi; Breaking Out of a
    Sandboxed Virtual Machine. We have
  • 1:57 - 2:05
    demonstrated this exploit chain before at
    GeekPwn 2018. I will introduce our
  • 2:05 - 2:12
    experience of escaping the sandbox on the
    ESXi. I will also introduce the work we
  • 2:12 - 2:23
    have done about the sandbox on the ESXi.
    Now let's start it. We come from the
  • 2:23 - 2:29
    Chaitin Security Research Lab. We have
    researched many practical targets in
  • 2:29 - 2:36
    recent years, including PS4 jailbreak,
    Android rooting, IoT offensive research,
  • 2:36 - 2:44
    and so on. Some of us also play CTF with
    Team b1o0p and Tea Deliverers. We recently
  • 2:44 - 2:52
    own the championship at HITCON final. We
    are also the organizer of the Real World
  • 2:52 - 2:59
    CTF. We've created some very hard
    challenges this year. So if you are
  • 2:59 - 3:09
    interested in it, we welcome you to
    participate in our CTF game. Now, before
  • 3:09 - 3:16
    we start our journey to escaping the
    virtual machine, we need to figure out
  • 3:16 - 3:25
    what is virtual machine escape? I like to
    ask some of you that, did anyone use the
  • 3:25 - 3:32
    virtualization software? If you have used
    the virtualization software, like VMware
  • 3:32 - 3:41
    Workstation, Hyper-V, VirtualBox and so
    on, please raise your hand. Okay, okay,
  • 3:41 - 3:50
    okay. Thanks, thanks, thanks. Many. So if
    you are a Software Engineer or a Security
  • 3:50 - 3:59
    Researcher, you'll probably have used
    virtualisation software, but if anyone has
  • 3:59 - 4:04
    heard of the word virtual machine escape,
    if you have heard of that, please raise
  • 4:04 - 4:13
    your hand again. Oh, oh, surprised.
    Thanks, thanks, thanks. It surprises me
  • 4:13 - 4:21
    that all you know about that, but I have
    to introduce that again. What's virtual
  • 4:21 - 4:25
    machine escape? You know, in most
    circumstances the host OS runs on the
  • 4:25 - 4:33
    hypervisor and the hypervisor will handle
    some sensitive instructions executed by
  • 4:33 - 4:40
    the guest OS. Host OS emulates virtual
    hardware and handles RPC requests from the
  • 4:40 - 4:50
    guest OS. That's the architecture of
    normal virtualization software. And the
  • 4:50 - 4:59
    guest OS is isolated from each other and
    cannot affect the host OS. However, if
  • 4:59 - 5:05
    there are some bugs, or if there are some
    vulnerabilities existing in the host OS,
  • 5:05 - 5:13
    it's possible for the guest OS to escape
    from the virtualization environment. They
  • 5:13 - 5:21
    can exploit these vulnerabilities. And
    finally, they can execute arbitrary code
  • 5:21 - 5:31
    on the host. So this is the Virtual
    Machine Escape. Then why we chose ESXi as
  • 5:31 - 5:39
    our target? The first reason is we know
    that more and more companies are using or
  • 5:39 - 5:49
    plan to use private cloud to store its
    private data, including these companies
  • 5:49 - 5:57
    and the vSphere is an enterprise solution
    offered by VMware. It's popular between
  • 5:57 - 6:03
    companies. If you are a Net-Manager of a
    company, you may know about VMware
  • 6:03 - 6:12
    vSphere. And the ESXi is the hypervisor
    for VMware vSphere, so it's widely used in
  • 6:12 - 6:18
    private cloud. That's the first reason.
    The second one is that it's a challenging
  • 6:18 - 6:25
    target for us. There are several
    exploitations of VMware Workstation in
  • 6:25 - 6:31
    recent years. Hackers escape from the
    VMware Workstation by exploiting some
  • 6:31 - 6:39
    vulnerabilities. These vulnerabilties
    exist in graphic cards, network cards and
  • 6:39 - 6:49
    USB devices and so on. But, there has been
    no public escape of ESXi before, so it's a
  • 6:49 - 6:58
    challenging target for us and we love
    challenge. Then why is the ESXi so
  • 6:58 - 7:05
    challenging? The first reason I think is
    that there are little documents about its
  • 7:05 - 7:14
    architecture. The only thing we have found
    is a white paper offered by VMware. The
  • 7:14 - 7:20
    white paper only includes some definitions
    and pictures without details. So let's
  • 7:20 - 7:29
    take a brief look at the architecture of
    ESXi first. ESXi is an Enterprise bare-
  • 7:29 - 7:36
    metal hypervisor and it includes two
    parts. The kernel, it uses VMKernel
  • 7:36 - 7:42
    developed by VMware and the User Worlds
    and the other part, the User Worlds. The
  • 7:42 - 7:51
    VMKernel is a POSIX-like operating system.
    And it is uses an in-memory filesystem. It
  • 7:51 - 7:59
    means that all files stored in this system
    are not persistent. And the VMKernel also
  • 7:59 - 8:08
    manages hardware and schedules resource
    for ESXi. VMKernel also includes VMWare
  • 8:08 - 8:15
    drivers, I/O Stacks and some User World
    APIs offered to the User Worlds. And the
  • 8:15 - 8:26
    word "User World" is used by VMWare to
    refer the processes running in VMKernel
  • 8:26 - 8:32
    operating system and the word "User World"
    means that a group of these processes.
  • 8:32 - 8:38
    This process can only use a limited /proc
    directory and limited signals and it can
  • 8:38 - 8:45
    just use some of the POSIX API. For
    example, there are some User Worlds
  • 8:45 - 8:56
    processes like hosted, ssh, vmx and so on.
    Then this is the architecture of ESXi. I
  • 8:56 - 9:03
    would like to give you an example to show
    how a virtual machine works on ESXi. The
  • 9:03 - 9:09
    VMX process in the User World can
    communicate with the VMM by using some
  • 9:09 - 9:19
    undocumented customized system call. And
    the VMM will initialize the environment
  • 9:19 - 9:27
    for the guest OS. When guest OS executes
    some sensitive instructions, it will cause
  • 9:27 - 9:35
    a VMExit and return to VMM. The VMX
    process also emulates virtual hardware and
  • 9:35 - 9:41
    handles RPC requests from the guest.
    That's how a virtual machine works on
  • 9:41 - 9:49
    ESXi. Then, how can we escape from the
    virtual machine on ESXi? If there is a
  • 9:49 - 9:58
    vulnerability in the virtual hardware of
    the VMX, we can write a driver, or write
  • 9:58 - 10:07
    an exploit, to escape from it. The driver
    will communicate with the virtual hardware
  • 10:07 - 10:14
    and it can exploit the vulnerability. And
    finally we can execute shellcode in the
  • 10:14 - 10:20
    VMX process. So it means that we have
    successfully escaped from the virtual
  • 10:20 - 10:28
    machine on the ESXi. So the second reason
    about why ESXi is so challenging, is that
  • 10:28 - 10:40
    User World API. The VMX uses many
    undocumented and customized system calls
  • 10:40 - 10:47
    and if you want to reverse some code of
    VMX it is hard for you to understand which
  • 10:47 - 10:56
    API the VMX is using. But luckily we found
    two system call tables after compromising
  • 10:56 - 11:05
    the k.b00 field. There are 2 system call
    tables we found with symbols so this field
  • 11:05 - 11:12
    will be useful if we want to reverse some
    code of the VMX. This is the second
  • 11:12 - 11:21
    reason. Thirdly, there are some security
    mitigations here, including ASLR and NX.
  • 11:21 - 11:27
    It means that we need to link some address
    information before we start our exploit
  • 11:27 - 11:35
    to break the randomness of the address
    space. Furthermore after testing we found
  • 11:35 - 11:44
    that there is another mitigation on the
    ESXi. There is a sandbox that isolates the
  • 11:44 - 11:51
    VMX process. So even if you can execute
    some shellcode in the VMX process you can
  • 11:51 - 11:58
    not execute any commands, you can not read
    any sensitive fields, unless you escape
  • 11:58 - 12:07
    from the sandbox either. And finally, we
    think that the VMX of ESXi has a smaller
  • 12:07 - 12:14
    attack surface. After comparison of the
    VMX binary between the Workstation and the
  • 12:14 - 12:21
    ESXi we found that there are some function
    that have been moved from the VMX in User
  • 12:21 - 12:28
    World to the VMKernel. For example the
    packet transmission function in the e1000
  • 12:28 - 12:38
    net card has been moved from the VMX to
    the VMKernel. And if you have read some
  • 12:38 - 12:45
    security advisories published by VMware
    recently, you can notice that there are
  • 12:45 - 12:53
    many vulnerabilites existing in the packet
    transmission part of the e1000 net card.
  • 12:53 - 13:01
    And all these vulnerabilites only affect
    Workstation. So we think that the VMX of
  • 13:01 - 13:10
    ESXi has a smaller attack surface. Now
    let's start the journey of escaping from
  • 13:10 - 13:18
    the ESXi. Let's overview the entire
    exploit chain first. We use 2 memory
  • 13:18 - 13:24
    corruption vulnerabilites in our exploit.
    The first one is an uninitialized stack
  • 13:24 - 13:32
    usage vulnerability which CVE Number is
    CVE-2018-6981. And the second is an
  • 13:32 - 13:41
    unitialized stack read vulnerability and
    the CVE number is CVE-2018-6982. And we
  • 13:41 - 13:47
    can do arbitrary address free by using the
    first vulnerability, and we can get
  • 13:47 - 13:53
    information leakage from the second one.
    After combining of these two
  • 13:53 - 14:00
    vulnerabilites we can do arbitrary
    shellcode execution in VMX process. And
  • 14:00 - 14:10
    finally we use a logic vulnerability to
    escape the sandbox of VMX and reverse a
  • 14:10 - 14:17
    root shell from the ESXi. So that's the
    entire exploit chain we use. Now let's
  • 14:17 - 14:24
    start the first one. The first
    vulnerability is an uninitialized stack
  • 14:24 - 14:33
    usage vulnerability. It exists in VMXNET3
    netcard. When the VMX VMXNET3 netcard
  • 14:33 - 14:40
    tries to execute command
    UPDATE_MAC_FILTERS it will us a structure
  • 14:40 - 14:48
    on the stack, the PhysMemPage structure.
    This structure is used to represent the
  • 14:48 - 14:54
    memory mapping between the guest and the
    host. And it's also been used to transport
  • 14:54 - 15:02
    data between the guest and the host. Then
    the VMXNET will call function
  • 15:02 - 15:08
    DMA_MEM_CREATE to initialize the structure
    on the stack first, then it will use this
  • 15:08 - 15:16
    structure to execute this command. And
    finally it uses PhysMemRelease to destroy
  • 15:16 - 15:23
    the structure, the physical memory page
    structure. So it seems that there are no
  • 15:23 - 15:31
    problems here. But if we look at the
    function DMA memory create, we can notice
  • 15:31 - 15:40
    that there is a check before the
    initialization of the PhysMemoryPage
  • 15:40 - 15:47
    structure. It will check the argument
    address and the argument size and if the
  • 15:47 - 15:54
    check passes then it will initialize the
    structure. But if the check fails, it will
  • 15:54 - 16:02
    never initialize the structure on the
    stack. And finally we found that we can
  • 16:02 - 16:13
    control the address argument by writing a
    value to one of the registers of VMXNET3.
  • 16:13 - 16:18
    What is worse is that in function
    PhysMemoryRelease there are no checks
  • 16:18 - 16:25
    about if the PhysMemoryPage structure had
    been initialized and it just frees a
  • 16:25 - 16:34
    pointer of this structure. So that's it
    about it. If we can pad the data on the
  • 16:34 - 16:42
    stack it's possible for us to do arbitrary
    address free. We can pad a fake
  • 16:42 - 16:48
    PhysMemoryPage structure on the stack and
    then make the check fail in the function
  • 16:48 - 16:54
    DMA memory create and finally when it
    comes to the PhysMemoryRelease it will
  • 16:54 - 17:02
    free a pointer of our PhysMemoryPage
    structure. So we just try to find a
  • 17:02 - 17:10
    function to pad the data on the stack.
    There is a design pattern in software
  • 17:10 - 17:18
    development, where we store the data into
    the stack, if the size is small, when we
  • 17:18 - 17:26
    allocate some memory. And otherwise we
    will output it to the heap. And we found a
  • 17:26 - 17:34
    function that fits this pattern. This
    function will be used when our guest OS
  • 17:34 - 17:41
    executes the instruction outsb. It will
    check the size, if the size is smaller
  • 17:41 - 17:48
    than 0x8000 it will use the stack to store
    the data. And finally it will copy the
  • 17:48 - 17:56
    data we send from the guest into the
    stack. So we can use this function to pad
  • 17:56 - 18:03
    the data on the stack. Then how do we
    combine this to do arbitrary address free?
  • 18:03 - 18:11
    We can use outsb instruction in guest OS
    first to pad the data on the stack. This
  • 18:11 - 18:19
    data should contain fake PhysMemoryPage
    structure and the page count of this fake
  • 18:19 - 18:26
    structure should be zero. The page array
    of this fake PhysMemoryPage structure
  • 18:26 - 18:34
    should be the address we want to free.
    Then we set some registers of the vmxnet3
  • 18:34 - 18:41
    to make the check fail in the function DMA
    memory create. And finally, we order the
  • 18:41 - 18:50
    vmxnet3 netcard, to execute the command to
    update MAC filters and then in the VMX it
  • 18:50 - 18:57
    will use the PhysMemRelease to destroy the
    structure we pad before. This structure is
  • 18:57 - 19:05
    a fixed structure with pad in the first
    step and it will check the page count if it's 0. If
  • 19:05 - 19:12
    it's 0, it will free the page
    array of this fake PhysMemPage structure.
  • 19:12 - 19:18
    So we can do arbitrary address free now by
    using the first uninitialized stack usage
  • 19:18 - 19:26
    vulnerability. Here come the next one, the
    second vulnerability also exists in the
  • 19:26 - 19:34
    vmxnet3 net card. The vmxnet3 net card
    tries to execute command get_coalesce. It
  • 19:34 - 19:43
    will first get a length from the guest,
    and the length must be 16. Then it
  • 19:43 - 19:52
    initializes the first eight byte of a
    structure on the stack. But it's just for
  • 19:52 - 19:58
    guest to initialize the next 8 byte of
    this structure and just write this
  • 19:58 - 20:07
    structure back to our guest OS. So we can
    link 8 byte uninitialized data on the
  • 20:07 - 20:14
    stack from the host to our guest. And
    after debugging the guest VMX process, we
  • 20:14 - 20:20
    realized that there are fixed offsets
    between the images, so it's possible for
  • 20:20 - 20:31
    us to get all the information about the
    address space by using this vulnerability.
  • 20:31 - 20:38
    Now, what do we have now? We can do
    arbitrary address free by using the first
  • 20:38 - 20:45
    one. And we can get all information about
    the address space by using the second one.
  • 20:45 - 20:51
    What do we want to do? We want to do
    arbitrary shell code execution in the
  • 20:51 - 20:58
    VMX. So how do we combine these two
    vulnerabilities to achieve our target?
  • 20:58 - 21:03
    It's hard for us to do arbitrary shell
    code execution by using arbitrary address
  • 21:03 - 21:09
    free. But it's easy for us to do arbitrary
    shell code execution by using an arbitrary
  • 21:09 - 21:17
    address write. So our target changes into
    how to do arbitrary address write by using
  • 21:17 - 21:26
    arbitrary address free. Then we realized
    that we need a structure and this
  • 21:26 - 21:34
    structure should include pointers we can
    write and the size. So last we can
  • 21:34 - 21:40
    overwrite this structure. We can do
    arbitrary address writes usually. When we
  • 21:40 - 21:49
    first tried to exploit this vulnerability,
    we used some structures in the heap, but
  • 21:49 - 21:57
    we've found that we can not manipulate the
    heap's layout stably because VMX
  • 21:57 - 22:04
    frequently allocates and releases
    memory. So we cannot use the structures in
  • 22:04 - 22:12
    the heap. And after reversing some code of
    VMX, we have found a structure. The
  • 22:12 - 22:20
    structure's name is channel and it's used
    in VMWare RPCI. What's VMWare RPCI?
  • 22:20 - 22:27
    VMWare has a series of RPC mechanisms to
    support communication between the guest
  • 22:27 - 22:33
    and the host. And here it has an
    interesting name: backdoor. RPCI is one of
  • 22:33 - 22:40
    them. And the other one we may be familiar
    with is VMWare tools. I'd like to ask
  • 22:40 - 22:47
    again if anyone has installed VMWare tools
    in your guest OS, please raise your hands
  • 22:47 - 22:58
    again. Oh, not as much as before. So if
    you use VMWare workstation, you'll
  • 22:58 - 23:05
    probably have installed VMWare tools in
    your guest because once you installed it,
  • 23:05 - 23:13
    you can use some convenient functions such
    as copy and the paste text fields between
  • 23:13 - 23:21
    the guest and the host, drag and drop
    files, create shared folder and so on.
  • 23:21 - 23:30
    VMWare tools are implemented by using some
    RPCI commands. And here are some examples
  • 23:30 - 23:38
    about about some RPCI commands. For
    example, we can use info-set guestinfo to
  • 23:38 - 23:44
    set some information about our guest and
    we can use info-get to retrieve this
  • 23:44 - 23:55
    information back. Then what happens when
    we execute this RPCI command in our guest?
  • 23:55 - 24:03
    For example, if we execute this RPCI
    command 'info-set guestinfo.a' 123 in our
  • 24:03 - 24:13
    guest OS. What happens in VMX? It will
    call VM Exit first and finally it will return
  • 24:13 - 24:23
    to the RPCI handler of VMX. Then the RPCI
    handler will choose a subcommand to use by
  • 24:23 - 24:32
    checking the value of the registers of our
    guest OS. The RPC tool in our guest OS
  • 24:32 - 24:40
    will use the subcommand, 'Open' first to
    open a channel and initialize it. Then it
  • 24:40 - 24:50
    will use a subcommand, 'SendLen' to set
    the size of our channel and allocate heap
  • 24:50 - 24:56
    memory to install the data of our RPC
    command and suddenly it will use the
  • 24:56 - 25:08
    'SendData' subcommand to pad the data of
    the memory we allocated before. And once
  • 25:08 - 25:16
    the length of the data we sent from the
    guest re-calls to the sizeof from the
  • 25:16 - 25:23
    'SendLen' subcommand the VMX will use a
    corresponding RPCI command handler
  • 25:23 - 25:31
    function after a string combination. And
    finally, it will use a 'Close' subcommand
  • 25:31 - 25:38
    to destroy the channel structure including
    setting the size to zero and freeing the
  • 25:38 - 25:47
    data pointer. That's what happens when we
    execute this RPCI commend in our guest.
  • 25:47 - 25:55
    Furthermore, there is a channel structure
    area in the data segment we can use. So
  • 25:55 - 26:04
    this is a perfect structure for our
    exploit. Now, you got all the things we
  • 26:04 - 26:10
    want. We've got two vulnerabilities and
    we've got the structure we want. How do we
  • 26:10 - 26:20
    combine this? We notice that the VMX uses
    ptmalloc of Glibc to manage its heap. So
  • 26:20 - 26:26
    we just choose to use a fast-bin attack.
    What's the fast-bin attack? Fast-bin
  • 26:26 - 26:32
    attack is a method to exploit heap
    vulnerabilities of ptmalloc by using the
  • 26:32 - 26:41
    singly-linked list. And it's the easiest
    exploit method to exploit ptmalloc, I
  • 26:41 - 26:49
    think. It's also the first method to
    exploit ptmalloc that I learned when I
  • 26:49 - 26:57
    just started to learn how to how to
    exploit. Then after considering the check
  • 26:57 - 27:06
    existing in the Glibc, we decided to free
    the address at the Reply Index of channel.
  • 27:06 - 27:15
    Because by doing that, the Glibc will treat
    this address as a fake chunk and the Glibc
  • 27:15 - 27:23
    will check the current chunk's size. And
    after doing that, the size of the fake
  • 27:23 - 27:30
    chunk is also the size of the
    'channel[N]', so we can set a valid value
  • 27:30 - 27:39
    to the size of the 'channel[N]' to bypass
    the check. So we can bypass the check.
  • 27:39 - 27:47
    Once we've freed this address this fake
    chunk will be put into the fast-bin linked
  • 27:47 - 27:59
    list first. Then we can reallocate this
    fake chunk by using another channel, N+2.
  • 27:59 - 28:08
    Now we have a data pointer pointed at the
    reply index of channel[N] and we can
  • 28:08 - 28:16
    easily overwrite the channel[N+1] by using
    channel[N+2]. We can send a data to
  • 28:16 - 28:24
    channel[N+2] and finally it will overwrite
    some parts of the channel[N+1]. So it's
  • 28:24 - 28:29
    easy now for us to do arbitrary address
    write by faking some parts of the channel
  • 28:29 - 28:39
    structure. Do remember our target? Our
    target is to do arbitrary shell code
  • 28:39 - 28:47
    execution in VMX and we can do arbitrary
    address write now. There are many ways to
  • 28:47 - 28:52
    do arbitrary shell code execution by using
    arbitrary address write. We choose to use
  • 28:52 - 29:03
    a ROP. We can override the '.got.plt'
    segment. We can fake the channel[N+1],
  • 29:03 - 29:11
    structure first, overwrite the data
    pointer at channel[N+1] to the address of
  • 29:11 - 29:22
    .got.plt segment. Then we can overwrite
    the function pointer on the .got.plt
  • 29:22 - 29:31
    segment. So once the VMX uses this
    function we overwrite, it will jump to our
  • 29:31 - 29:41
    ROP gadget. So it's also easy for us to do
    arbitrary shell code execution by using
  • 29:41 - 29:50
    ROP. So now we can do arbitrary shell code
    execution in the VMX process. We're seeing
  • 29:50 - 29:57
    that we have escaped from the virtual
    machine of the ESXi fully, we tried to
  • 29:57 - 30:06
    execute some command by using a system
    call execve, but it fails. We tried to
  • 30:06 - 30:14
    open and read some sensitive files just
    like password, it fails again. Then we
  • 30:14 - 30:23
    realize that there is a sandbox. We cannot
    execute any commands unless we escape the
  • 30:23 - 30:32
    sandbox either. The next part come to
    comes to the how we analyze and the
  • 30:32 - 30:42
    escape the sandbox. After realizing that
    there is a sandbox in the ESXi, we reverse
  • 30:42 - 30:48
    some code of the VMkernel and we find the
    kernel module named as VM Kernel SAS
  • 30:48 - 30:55
    control system. And this system, this
    module, implements the fine grained checks
  • 30:55 - 31:04
    for the system call. And it seems that
    this sandbox is a rule-based sandbox. So
  • 31:04 - 31:10
    we just tried to find the configuration
    file of this sandbox. We finally found it
  • 31:10 - 31:16
    at this directory,
    /etc/vmware/secpolicy/domains, and it
  • 31:16 - 31:25
    seems that there are many different
    sandboxes offered by VMWare to the
  • 31:25 - 31:34
    different processes in the userworld. Like
    app, plugin and the globalVMDom is a file
  • 31:34 - 31:44
    for our VMX process and for our VM. After
    reading that, it's obvious for us that the
  • 31:44 - 31:51
    /var/run directory is the only directory
    where we have read and write permissions.
  • 31:51 - 31:59
    Then we look at the files existing in this
    directory. We got a lot of pid filess just
  • 31:59 - 32:08
    like crond, dcui, inetd and so on. And
    it's also obvious that inetd.conf
  • 32:08 - 32:19
    configure file is only configure file we
    can write. What's inetd? inetd is open
  • 32:19 - 32:28
    source software and it's a super-server
    domain that provides internet services.
  • 32:28 - 32:35
    Then we just analyze the contents of the
    inetd.conf. The content of the inetd.conf
  • 32:35 - 32:44
    is here on the ESXi. We can find that it a
    defines two services, ssh and the authd.
  • 32:44 - 32:50
    And some of it defines which binary will
    be used by different services. For
  • 32:50 - 33:03
    example, the authd will be used by the
    authd services. Also after some testing,
  • 33:03 - 33:09
    we realize that the authd service is
    always enabled, while the sshd service is
  • 33:09 - 33:17
    not. So this is the only configure file we
    can write. So we got an idea. How about
  • 33:17 - 33:24
    overwriting this configure file? Or we can
    overwrite the binary part for authd like
  • 33:24 - 33:32
    that, we can override the /sbin/authd to
    /bin/sh. So once can restart the inetd
  • 33:32 - 33:41
    process we can bind the shell to the port
    authd is using. Then we just find a way to
  • 33:41 - 33:49
    restart the inetd process. We analyzed the
    configure file of the sandbox again, and
  • 33:49 - 33:55
    we found out the queue system call we can
    use in the VMX process. Then we just use
  • 33:55 - 34:04
    the queue HUP to restart the inetd
    process. Once the inetd process restarts,
  • 34:04 - 34:12
    we can execute any commands by sending
    them to the port the authd is using. So
  • 34:12 - 34:24
    that's the method we use to escape from
    the sandbox. And here's a demo.
  • 34:24 - 34:43
    Oh, sorry.
  • 34:43 - 34:50
    Oh, it seems not, I cannot play this
    video, but it's OK. You can find it on
  • 34:50 - 34:59
    YouTube and we created this demo after
    the GeekPwn 2018, we get a reverse shell
  • 34:59 - 35:11
    after excuting the exploit in our guest
    OS. That's all. And if you want to get
  • 35:11 - 35:17
    more details about our exploit chain,
    please check our paper here and that's
  • 35:17 - 35:19
    all. Thanks.
  • 35:19 - 35:30
    applause
  • 35:30 - 35:34
    Herald: So I don't think I'm actually
    worthy to share the stage with
  • 35:34 - 35:40
    f1yyy, that was awesome. If you have
    questions, we have microphones, you need
  • 35:40 - 35:46
    to come up to the microphone, line up
    behind them and we'll take your question.
  • 35:46 - 35:53
    Meanwhile, does the signal angel have
    anything? No questions yet. Do we not have
  • 35:53 - 35:58
    questions from the audience? There is one.
    Can I have number six, please?
  • 35:58 - 36:04
    Mic 6: Do you talk to VMWare for this
    little hack?
  • 36:04 - 36:11
    f1yyy: We have reported all these
    vulnerabilities to VMWare after the
  • 36:11 - 36:19
    GeekPwn 2018, and it has been one year
    since after they repair it.
  • 36:19 - 36:25
    Mic 6: OK, Thanks.
    Herald: That's definitely a relief. Number
  • 36:25 - 36:29
    one, please.
    Mic 1: First of all, thanks for the great
  • 36:29 - 36:34
    talk. I just want to know if there is any
    meaningful thing a system administrator
  • 36:34 - 36:42
    can do to lock down the sandbox further so
    that we can have some preventative,
  • 36:42 - 36:48
    basically tasks, for our ESXi setups. Or
    if there is nothing we can do except
  • 36:48 - 36:55
    patching, of course.
    f1yyy: Could you repeat your question?
  • 36:55 - 37:02
    It's so fast for me. Sorry about that.
    Mic 1: Basically, is there anything you
  • 37:02 - 37:09
    can do as an administrator to lock down
    the sandbox even more so that this is
  • 37:09 - 37:12
    impossible or that it is harder than what
    you showed?
  • 37:12 - 37:19
    f1yyy: OK. This is the first question.
    Your can set the sandbox down by executing
  • 37:19 - 37:30
    a command on the ESXi shell. I didn't put
    the command here. I found the command to
  • 37:30 - 37:39
    set the sandbox down. You can find it by
    searching the documents about the ESXi.
  • 37:39 - 37:49
    Wait, wait, wait, wait. I found it, just
    by myself by using the command offered on
  • 37:49 - 38:00
    the ESXi shell. It's not documented by the
    VMWare. OK, I will share this command on
  • 38:00 - 38:06
    my Twitter later. Sorry about that. I
    didn't put this command into my slides.
  • 38:06 - 38:10
    Mic 1: But would this have prevented the
    attack?
  • 38:10 - 38:17
    f1yyy: Prevented it?
    Herald: By doing that change, by doing
  • 38:17 - 38:23
    that command, would be possible to prevent
    the attack that you just showed?
  • 38:23 - 38:34
    f1yyy: The sandbox is used to protect the
    VMX process. So if you update your ESXi, I
  • 38:34 - 38:41
    think that it will be safe.
    Herald: Okay, great. We have a we have a
  • 38:41 - 38:45
    question from the Internet.
    Signal Angel: Yes. Does this exploit also
  • 38:45 - 38:52
    work on non-AMD VTx enabled VMs using binary
    translation?
  • 38:52 - 38:58
    Herald: Is it is it more universal than
    just the AMD-VX?
  • 38:58 - 39:03
    f1yyy: Yeah, can you repeat that again?
    I just hear the, okay.
  • 39:03 - 39:13
    Signal Angel: Does it also work on non-AMD
    V or VTX-enabled VMs using binary
  • 39:13 - 39:20
    translation?
    f1yyyy: Yes, because all these
  • 39:20 - 39:27
    vulnerabilities exist in the virtual
    hardware. You will need to use virtual
  • 39:27 - 39:35
    hardware in your virtual machine.
    Herald: So any further questions? I'm not
  • 39:35 - 39:40
    seeing anybody on the microphones. Any
    further questions from the internet?
  • 39:40 - 39:48
    That's it then. Good. Please, everybody help
    me in thanking f1yyyy for this fantastic talk.
  • 39:48 - 39:51
    applause
  • 39:51 - 39:56
    36c3 postroll music
  • 39:56 - 40:18
    Subtitles created by c3subtitles.de
    in the year 2020. Join, and help us!
Title:
36C3 - The Great Escape of ESXi
Description:

more » « less
Video Language:
English
Duration:
40:18

English subtitles

Revisions