• Stars
    star
    506
  • Rank 87,236 (Top 2 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A research kernel and hypervisor attempting to get fully deterministic emulation with minimum performance cost

Orange Slice

Orange Slice is a research kernel and hypervisor with an end goal of creating a deterministic hypervisor. This will be developed almost entirely in my free time, and will probably move slow. However I will try to stream almost all dev for this project, such that people can ask questions and hopefully learn a thing or two about kernel and hypervisor development!

This deterministic hypervisor is going to be designed from the start for fuzzing. Having determinism in a hypervisor would allow us to never have an issue with reproducing a bug, regardless of how complex the bug is. However as a hypervisor we will benefit from the performance of hardware-accelerated virtualization.

TL;DR

The end goal is a deterministic hypervisor, capable of booting Windows and Linux, with less than a 5x performance slowdown to achieve instruction-and-cycle level determinism for cycle counts and interrupt boundaries.

About Me

Twitter

My Blog

My Youtube Channel

Intro Video to the project

Youtube Video

Mascot

Orange Slice Squishable

This is going to be developed live?

Yup. Check out My Youtube Channel or my Twitter. I announce my streams typically a few hours ahead of time, and schedule the streams on Youtube. Further for streams I think are more impactful, I try to schedule them a few days out.

I'm going to try to do much of the development live, and I'll try to help answer any questions about why certain things are being done. If this project fails, but I teach some people about OS development and get other excited about security research, then it was a success in my eyes.

Project Development

This will be a bootloader, kernel, and hypervisor written entirely in Rust (except for the stage0 in assembly). I already have a couple research kernels written in Rust which I will likely borrow code from.

I haven't quite determined the design of the kernel yet, but it will be multiprocessing from day one (support for SMP systems, but only single-core guests for now). I have a 256-thread Xeon Phi which I use to stress the scalability and design of the kernel. I already have many different kernel models I've experimented with before for hypervisor development, so hopefully we'll be able to make informed decisions based on past experiences.

Building

Have nasm, lld-link (from LLVM), python (I use Python 3), and Rust nightly (with i586-pc-windows-msvc and x86_64-pc-windows-msvc targets installed)

Run cargo run in the root directory. Everything should be built :)

Using

Copy orange_slice.boot and orange_slice.kern to a TFTPD server folder configured for PXE booting. Also set the PXE boot filename to orange_slice.boot in your DHCP server.

Previous public hypervisor work

Hypervisor for fuzzing written in C

Hypervisor for fuzzing written in assembly

What is determinism?

When running an operating system there are many different things going on. Things like cycle counts, interrupts, system times, etc, all vary during execution. On an x86 processor you'd struggle to ever get an external interrupt to come in on the same instruction boundaries, or read the same value from rdtsc.

This non-determinism means that you cannot simply run a previous crashing input through again and observe the same result. Things like ASLR state can be influenced by external interrupts and timers, and things like task switches also are influenced by these. Race conditions are typically extremely hard to get to reproduce, and this project aims at doing that with all the performance benefits of a hypervisor.

What do we consider determinism?

If our goal is to develop a deterministic hypervisor, it's important that we lay down some ground rules of what we consider in scope, and not.

  • The hypervisor must return the same results from all emulated devices
    • If a time is queried from a PIT/APIC/RDTSC, the same time must be returned as was in prior executions from the same snapshot
  • External interrupts must be delivered on the same instruction boundaries
    • If we cannot fulfill this goal directly, then we must have a way to determine we "missed" a boundary and restore to a previous known good state which we can "try again".
  • We should be able to set breakpoints on future events that we know will happen from a previous execution. This allows us to time travel debug, go back in time, and set a breakpoint on a previously observed condition.
  • Probably some more... as we tailor our goals based on successes and failures

Ultimately we should be able to boot the BIOS, boot into Windows, and finally launch an application that requests the cycle count, and that cycle count should be predictable based on prior runs, and all context switches should have occurred up to that point at deterministic times.

Why?

With my amazing team at Microsoft, we're working on a fully deterministic system level fuzzing tool (this will be open source for everyone soon, likely by late 2019, but no promises!). This is built on the existing system emulator Bochs; but with many modifications to provide APIs for fuzzing, introspection, and system-level time travel debugging. There's also some pretty nutty architecture that was designed to ensure determinism, we can't wait to share and talk about what we've done!

We made a decision early on in the project, that determinism is more important than performance. Determinism allows us to provide users with system-level time travel debugging, allowing high quality bug reports with the net effect of eliminating all "no-repro" bugs.

We have already used our new deterministic tooling to reliably reproduce obscure race conditions that historically we were unable to reproduce well enough to fix!

But, with Bochs comes a 50-100x performance slowdown. Your Windows boot now takes an hour rather than a minute, and your fuzzer performance dramatically drops. However it's worth it for the determinism. We'd rather have 10 bugs get fixed, than "know" about 15 bugs and only fix a few of them.

The ultimate goal of this project is to bring this performance overhead down from the ~50-100x we have from Bochs, to a goal of <5x. 5x may seem high for a hypervisor, but we're probably going to have to expect interrupts "early" and walk up to the correct boundary to deliver an interrupt. This may have some emulation or single stepping involved.

If the microarchitecture is nice and predictable in certain situations, then hopefully we'll be able to find a good way to get this determinism with little cost. Otherwise we might have to do things a bit crude and get around the rough edges with partial emulation.

Timeframe

This project is not that important as it only fixes performance issues but none of the others we address with our Bochs approach, such as full-system taint tracking and the ability to fuzz hypervisors with full coverage, feedback, and determinism. It may also fail due to infeasibility, as hardware virtualization extensions are not designed with determinism in mind.

If this project succeeds, this project will likely be abandoned and a new one will be created that will be user oriented. This project is only for proving that it's possible, and exploring ways of accomplishing this goal... and of course teaching during the process!

More Repositories

1

chocolate_milk

Pure Rust x86_64 bootloader and kernel
Rust
478
star
2

mesos

Binary coverage tool without binary modification for Windows
Rust
405
star
3

applepie

A hypervisor for fuzzing built with WHVP and Bochs
C++
361
star
4

mempeek

A command line tool that resembles a debugger as well as Cheat Engine, to search for values in memory
Rust
217
star
5

fzero_fuzzer

A fast Rust-based safe and thead-friendly grammar-based fuzz generator
Rust
208
star
6

elfloader

An architecture-agnostic ELF file flattener for shellcode
Rust
207
star
7

falkervisor_grilled_cheese

C
168
star
8

cookie_dough

A fuzzing introspection tool
Rust
161
star
9

proc_mem_ida_loader

A /proc/mem IDA loader to snapshot a running process
Python
149
star
10

fuzz_with_emus

Why fuzzing with emulators is amazing
Rust
129
star
11

nginx_shitpost

Nginx 0-day on latest nginx
C
116
star
12

rv32i_jit

A super simple RV32i JIT, designed for ease of understanding and modification
C
76
star
13

lemonade

A debugger for Linux in Rust
Rust
76
star
14

falkervisor_beta

Assembly
75
star
15

basic_mutator

About as basic of a mutator as you can get, but it does the trick in most situations
Rust
55
star
16

slime_tree

Worst Android kernel fuzzer
Rust
43
star
17

falkhash

Exotic Shitty Hash Maybe
C
43
star
18

guifuzz

A GUI fuzzing application set up to fuzz calc.exe right now
Rust
36
star
19

riscv

A div-less, mul-less, atomic-less `rv64i` compiler toolchain using purely clang, musl, and compiler-rt
C
27
star
20

whylol

Shhh
Rust
27
star
21

adventures_in_fuzzing

Here's the slides and audio for a talk I did at NYU on the 13th of November 2018
27
star
22

init

A super simple /sbin/init for Linux which allows running one and only one program
Rust
22
star
23

vectorized_mmu

Snapshot of the vectorized MMU that lines up with the vectorized MMU blog
Rust
22
star
24

rust_mips_nt4

Rust development environment for MIPS on NT4
Rust
19
star
25

aflbench

An AFL scaling benchmarking tool
Python
18
star
26

flounder

Flounder is an old corpus collector I wrote, but it still works. Just need a Bing API key
Python
18
star
27

pdblister

Faster version of `symchk /om` for generating PDB manifests of offline machines
Rust
18
star
28

gamozolabs.github.io

Apparently this maybe blogs or something?
Ruby
16
star
29

fuzzyneural

A neural network using fuzzing-style feedback rather than back-propagation
Rust
16
star
30

vectorized_emulation_recon_2019

Gave a talk on Vectorized emulation at Recon Montreal 2019, here are the slides
16
star
31

cuddly_kangaroo

A static website generator that embeds all images as base64, and thus can be used with a single resource.
Rust
15
star
32

snuffles

A high-performance graphics API designed mainly for data visualization
Rust
15
star
33

hellscape

Playground for testing feedback
Assembly
14
star
34

helicopter_game

This is uhh, a "clone" of the helicopter game
Rust
13
star
35

canon_pixma_mx492

Reverse engineering project on stream
Rust
13
star
36

coverage_highlight

A very simple coverage highlighter for VIM
Python
12
star
37

freetype_harness

Definitely not for fuzzing
Rust
11
star
38

qemu_chrooter

Take a QEMU binary, copy the dependencies into a chroot
Rust
11
star
39

bridengroom

Windows Heap Loggin'
Rust
11
star
40

statusbar

A DWM status that shows the MPD playing song and the current datetime in milliseconds
Rust
10
star
41

libprocmem

A simple /proc/<pid>/{mem,maps} library for Rust
Rust
9
star
42

fuzztheory

A project for simulating fuzzing such that analysis can be done on coverage/feedback/scaling mechanisms
Rust
9
star
43

safecast

Safe casting in Rust!
Rust
7
star
44

ffmpegged

Uhh, trying to make encoding actually use cores
Rust
7
star
45

coff_nm

`nm` and `addr2line` but for DI "debug-info" COFF files
Rust
7
star
46

streamwrite

Benchmarking sequential i32 stores
Rust
6
star
47

teraflopter420

A helicoptor game engine with perf
Rust
6
star
48

bochs_determinism_test

Used to run 2 Bochs instances in lockstep to verify they do the same things
C++
5
star
49

noodle

A non-procedrual Rust serialization and deserialization library
Rust
4
star
50

fork_benchmarking

I get asked about this a lot
Rust
4
star
51

lossless_compression_tutorial

An old tutorial I wrote during class about 10 years ago. It's probably bad, don't use it.
3
star
52

server_simulator_2020

Simulates servers to find the best server to run for the cost
Rust
3
star
53

OnorineAutoCandy

An automated WoW chocolate addon
Lua
3
star
54

simple_slope_viewer

A basic 3d model viewer with a fly-based model. Designed for exploring WoW collision maps
Rust
2
star
55

font_test

Font test do not use ever
Rust
2
star
56

gamlang

Some ancient programming language I thought was a good idea
C
2
star
57

wow_priest_theorycraftin

Here we use supercomputers to optimize WoW characters, why not
Rust
1
star
58

onorine_jumps

A WoW addon for helping with doing tricky jumps and exploring
Lua
1
star
59

triangle_test

Testing triangles
Rust
1
star
60

ErannaAuctions

Dumping ground for auction data harvesting
Lua
1
star
61

FishingBuddy

The FishingBuddy addon for Classic WoW, but with per-hour stat tracking
Lua
1
star
62

speculation_data

Just some random data from an observed speculative session on Kaby Lake
Gnuplot
1
star
63

wow_classic_manatick_reversing

Trying to figure out exactly how mana ticks work in WoW vanilla
Lua
1
star