Skip to content

Instantly share code, notes, and snippets.

@pventuzelo
Created January 30, 2020 11:15
Show Gist options
  • Save pventuzelo/9a194eff2443c9f377969a2cca24d9d4 to your computer and use it in GitHub Desktop.
Save pventuzelo/9a194eff2443c9f377969a2cca24d9d4 to your computer and use it in GitHub Desktop.
Jfuzz fuzz target script for WebAssembly parsing library
const parser = require("@webassemblyjs/wasm-parser");
function fuzz(buf) {
try {
parser.decode(buf, {});
} catch (e) {
// Those are "valid" exceptions. we can't catch them in one line as
if (e.message.indexOf('Unexpected section') !== -1 ||
e.message.indexOf('Atomic instructions') !== -1 ||
e.message.indexOf('unknown table') !== -1 ||
e.message.indexOf('Internal failure') !== -1 ||
e.message.indexOf('Unexpected ') !== -1 ||
e.message.indexOf('magic header') !== -1 ||
e.message.indexOf('Unexpected') !== -1 ||
e.message.indexOf('typeof') !== -1 ||
e.message.indexOf('integer') !== -1 ||
e.message.indexOf('Unknown') !== -1 ||
e.message.indexOf('Unsupported') !== -1 ||
e.message.indexOf('data section') !== -1 ||
e.message.indexOf('unknown') !== -1 ||
e.message.indexOf('zero flag expected') !== -1 ||
e.message.indexOf('invalid UTF-8') !== -1 ||
e.message.indexOf('function signature') !== -1
) {}
else { throw e; }
}
}
module.exports = {
fuzz
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment