Created
January 30, 2020 11:15
-
-
Save pventuzelo/9a194eff2443c9f377969a2cca24d9d4 to your computer and use it in GitHub Desktop.
Jfuzz fuzz target script for WebAssembly parsing library
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
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