Environment setup for Browser Exploitation

The recommended stats are the following

  • Ubuntu 22.04

  • 16 GB of RAM

  • CPU with 8 Cores

These should be enough to compile and run everything we need.

Building Browsers

Chrome and Safari are open source so we can download and build our own copies to debug without having to reverse engineer anything.

There are generally two build flavors: Release and Debug

  • Debug

    • Binaries have all debug info and symbols and are larger in size because of that

    • Debug Asserts are present

    • Additional debugging tools are provided

  • Release

    • Binaries are smaller in size

    • No Debug Asserts

Building Chrome

The Chromium source tree is about 30GB of code in debug build, generally it's recommended to have 40GB of free space just for source and an additional 20GB for the release build.

Here are some useful links

  • Overall location: https://chromium.googlesource.com

  • Src Tree: https://chromium.googlesource.com/chromium/src.git

  • Github V8 Mirror: https://github.com/v8/v8

  • DEPS file: https://chromium.googlesource.com/chromium/src.git/+/refs/heads/master/DEPS

These are not the complete code as Chromium pulls a rather large amount of components from other locations. If we have a running Chrome instance we can view its version by visiting about:version.

To pull the Chromium code we'll need to install the Depot Tools (30GB of space)

and install the dependencies

Then we can generate the build file

and chose the build variables

We can configure more of these options

If we only want to build Chrome we can run

or if we just want a standalone V8 shell we can use the following

Building WebKit

WebKit is much smaller in size so about 20GB of free space should be enough for the build.

WebKit is tracked with SVN instead of git: https://trac.webkit.org/browser#webkit/branches If targeting Safari, find branch version in about menu:

To download the code we could download it from SVN which is slow, or download the archive of the repository directly from here; then we select the branch

Safari is for macOS and it's not available on Linux and Safari branches don't support GTK so we can build WebKit for UNIX using MiniBrowser. First of all we'll install the dependencies

and start the build

In order to build JavaScriptCore we'll use

To run WebKit with ASAN (Address Sanitizer), which will try to detect corruption and UAFs, we will need

Unified Builds combine source to speed up the compilation process, they're good for building but bad for debugging so we should disable JSC if needed keeping in mind that this will make the build process much slower

Code Browsing

  • Chromium sourecode: https://cs.chromium.org/chromium/

  • WebKit (JSC): http://ret2-webkit-woboq.s3-website-us-east-1.amazonaws.com/jsc/jsc/

Debugging the processes

To debug the browsers we need to find the right processes to attach to:

  • Chrome: to start a Chrome process for debugging use the following flags

When attaching a debugger like GDB to it we'll see

so to resume the process' execution we'll send the right signal and continue

Because of its size, fully debugging Chrome can be extremely slow; a way to get around that is to use gdb-add-index to cache debugging symbols or directly debugging the release build where symbols are completely missing.

  • WebKit: WebKit processes are much easier to find in the output of a command like ps fa, in this case we want to attack to the first WebKitWebProcess entry on the list

There are also some GDB debugging scripts we can use that take advantage of some special debugging commands some JS engines use (in debug builds)

Last updated