Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OOB read in main:150 #2

Open
andreafioraldi opened this issue Feb 8, 2020 · 1 comment
Open

OOB read in main:150 #2

andreafioraldi opened this issue Feb 8, 2020 · 1 comment

Comments

@andreafioraldi
Copy link

        file_size = filestatus.st_size;
        file_contents = (char*)malloc(filestatus.st_size);
        if ( file_contents == NULL) {
                fprintf(stderr, "Memory error: unable to allocate %d bytes\n", file_size);
                return 1;
        }

        fp = fopen(filename, "rt");
        if (fp == NULL) {
                fprintf(stderr, "Unable to open %s\n", filename);
                fclose(fp);
                free(file_contents);
                return 1;
        }
        if ( fread(file_contents, file_size, 1, fp) != 1 ) {
                fprintf(stderr, "Unable t read content of %s\n", filename);
                fclose(fp);
                free(file_contents);
                return 1;
        }
        fclose(fp);

        printf("%s\n", file_contents);

You read the file in file_contents and the print it. file_contents is not a string, if the file doen't contain a NUL byte at the end this will trigger a OOB read heap overflow.
This is not one of the artificial vulns and prevents the fuzzing using ASan cause it crashes even with the initial seed.

@andreafioraldi
Copy link
Author

Btw I found all the bugs using the dumb mode of afl-fuzz (-n) + ASan (commenting out printf("%s\n", file_contents);) so, unless you insert hard to reach vulns, this is really useless if you want to evaluate modern fuzzers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant