Skip to content

Several heap-BoF crashes from pcre2_compile related to parsed_pattern #561

@stevenagy

Description

@stevenagy

We found several crashing files (attached) through fuzzing the following program:

#include <stdio.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>

int main(int argc, char *argv[])
{
    FILE *f = fopen(argv[1], "rb");
    fseek(f, 0, SEEK_END);
    long size = ftell(f);
    rewind(f);
    char *fuzzData = (char*)malloc((size_t)size+1);
    fread(fuzzData, (size_t)size, 1, f);
    fuzzData[size] = '\0';

	int v0 = 1;
	size_t v1 = 1;
	pcre2_code_8* pcre2_compile_8val1 = pcre2_compile_8((PCRE2_SPTR8)fuzzData, size, 0, &v0, &v1, NULL);
   	return 0;
}

All crashes are heap-buffer-overflows stemming from the following source lines:

  • pcre2_compile.c:4014
  • pcre2_compile.c:4030
  • pcre2_compile.c:4304
  • pcre2_compile.c:4306
  • pcre2_compile.c:4307

These all appear to involve the parsed_pattern object.

We were able to reproduce the crashes using the PCRE2 OSS-Fuzz harness here after modifying it to read data from file: https://github.com/PCRE2Project/pcre2/blob/master/src/pcre2_fuzzsupport.c.

Any feedback on these crashes would be greatly appreciated. :)
crashes.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions