Git Product home page Git Product logo

Comments (3)

Navidem avatar Navidem commented on May 25, 2024

Additional heuristics to identify interesting functions to fuzz can be:

  • Functions where user-controlled (untrusted) data reach critical operations like memory alloc/dealloc, pointer arithmetic, etc. To realize this feature, we may employ taint analysis to track untrusted data propagation in the code. We may need an interface to let developer tag some data/function result as untrusted.

  • Generally recommend functions that perform error-prone operations (like the functions that make call to pointer returning functions in hope of capturing errors like null-deref). For this we may need a function profiler.

from fuzz-introspector.

DavidKorczynski avatar DavidKorczynski commented on May 25, 2024

We can generalise this issue and consider it to be improvements focused around "input to fuzz engines". This could for example include features such as automated dictionary generation by way of statically analysing code and data in the target

from fuzz-introspector.

DavidKorczynski avatar DavidKorczynski commented on May 25, 2024

I added a proof-of-concept for this. The focus atm is on dictionary generation by looking at constants used by each fuzzer in its reachable functions. Sample code for extracting strings used in fuzzer-reachable functions is here:

if (!getenv("FUZZINTRO_CONSTANTS")) {
continue;
}
//I.dump();
// Check if the operands refer to a global value and extract data.
for (int opndIdx = 0; opndIdx < I.getNumOperands(); opndIdx++) {
Value *opndI = I.getOperand(opndIdx);
//opndI->dump();
// Is this a global variable?
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(opndI)) {
GV->dump();
if (GV->hasInitializer()) {
Constant *GVI = GV->getInitializer();
if (ConstantData *GD = dyn_cast<ConstantData>(GVI)) {
//logPrintf(L1, "ConstantData\n");
// Integer case
if (ConstantInt *GI = dyn_cast<ConstantInt>(GD)) {
logPrintf(L1, "Constant Int\n");
uint64_t zext_val = GI->getZExtValue();
errs() << "Zexct val: " << zext_val << "\n";
}
}
else if (ConstantExpr *GE = dyn_cast<ConstantExpr>(GVI)) {
logPrintf(L1, "Constant expr: %s\n", GE->getName().str().c_str());
GE->dump();
if (GEPOperator* gepo = dyn_cast<GEPOperator>(GE)) {
errs() << "GEPOperator\n";
if (GlobalVariable* gv12 = dyn_cast<GlobalVariable>(gepo->getPointerOperand())) {
errs() << "GV - " << *gv12 << "\n";
if (gv12->hasInitializer()) {
errs() << "Has initializer\n";
Constant *C222 = gv12->getInitializer();
if (ConstantData *GD23 = dyn_cast<ConstantData>(C222)) {
errs() << "ConstantData\n";
if (ConstantDataArray *Carr = dyn_cast<ConstantDataArray>(GD23)) {
// This is constant data. We should be able to dump it down.
errs() << "ConstantArray. Type:\n";
Carr->getElementType()->dump();
errs() << "Number of elements: " << Carr->getNumElements() << "\n";
Type *baseType = Carr->getElementType();
if (baseType->isIntegerTy()) {
errs() << "Base types\n";
for (int i = 0; i < Carr->getNumElements(); i++) {
std::string s1 = toHex(Carr->getElementAsInteger(i));
errs() << "0x" << s1 << "\n";
}
}
if (Carr->isString()) {
errs() << "The string: " << Carr->getAsString() << "\n";
FuncWrap.ConstantsTouched.push_back(Carr->getAsString().str());
}
else {
errs() << "No this is not a string\n";
}
}
}
}

I have also refactored the code post-processing code so it is easier to develop individual analyses. The goal is to facilitate a plugin-like interface that makes it easy to rapidly develop new analysis techniques that rely on data collected from fuzz-introspector. Sample code in the post processor is here: https://github.com/ossf/fuzz-introspector/blob/main/post-processing/fuzz_html.py#L604-L622

I modified the simple-example-0 to display dictionary generation. For example for the following code:

char *global1 = "FUZZCAFE";
char *global2 = "FUZZKEYWORD";
int GLB2 = 0xbeef;
void unreached_target10(char *val) {
if (strcmp(val, global1) == 0) {
printf("Compare 1\n");
}
if (strcmp(val, global2) == 0) {
printf("Compare 15\n");
}

the automatic dictionary generator gives the suggested dictionary:

k0="FUZZCAFE "
k1="FUZZKEYWORD "

This can the be used as explicit input to fuzzers -dict=dictifile. There's more work to be done here

from fuzz-introspector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.