-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This Pull Request offers a basic VM fuzzer which relies on implied oracles (namely, "does it crash or timeout?"). It changes the following: - Adds an insns_remaining field to Context, denoting the number of instructions remaining to execute (only available when fuzzing) - Adds a JsNativeError variant, denoting when the number of instructions has been exceeded (only available when fuzzing) - Adds a VM fuzzer which looks for cases where Boa may crash on an input This offers no guarantees about correctness, only assertion violations. Depends on #2400. Any issues I raise in association with this fuzzer will link back to this fuzzer. You may run the fuzzer using the following commands: ```bash $ cd boa_engine $ cargo +nightly fuzz run -s none vm-implied ``` Co-authored-by: Addison Crump <addison.crump@cispa.de>
- Loading branch information
1 parent
ff02cd0
commit c1b5f38
Showing
9 changed files
with
153 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![no_main] | ||
|
||
mod common; | ||
|
||
use crate::common::FuzzSource; | ||
use boa_engine::Context; | ||
use boa_parser::Parser; | ||
use libfuzzer_sys::{fuzz_target, Corpus}; | ||
use std::io::Cursor; | ||
|
||
fn do_fuzz(original: FuzzSource) -> Corpus { | ||
let mut ctx = Context::builder() | ||
.interner(original.interner) | ||
.instructions_remaining(0) | ||
.build(); | ||
let mut parser = Parser::new(Cursor::new(&original.source)); | ||
if let Ok(parsed) = parser.parse_all(ctx.interner_mut()) { | ||
let _ = ctx.compile(&parsed); | ||
Corpus::Keep | ||
} else { | ||
Corpus::Reject | ||
} | ||
} | ||
|
||
fuzz_target!(|original: FuzzSource| -> Corpus { do_fuzz(original) }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![no_main] | ||
|
||
mod common; | ||
|
||
use crate::common::FuzzSource; | ||
use boa_engine::{Context, JsResult, JsValue}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fn do_fuzz(original: FuzzSource) -> JsResult<JsValue> { | ||
let mut ctx = Context::builder() | ||
.interner(original.interner) | ||
.instructions_remaining(1 << 16) | ||
.build(); | ||
ctx.eval(&original.source) | ||
} | ||
|
||
fuzz_target!(|original: FuzzSource| { | ||
let _ = do_fuzz(original); | ||
}); |