When GCLib reads a GFF line with no info segment, the char * at t[8] will not be set, causing it to take on whatever stale value happens to be in that location of the stack. Triggered accidentally, this can cause a segfault due to reading an invalid address here:
However, a maliciously crafted input may be able to place a valid pointer at this location, causing a more severe vulnerability.
Proposed Patch
At a minimum, t should be zeroed during initialization:
*** v0.12.7/gclib/gff.cpp 2021-07-23 10:31:39.000000000 -0400
--- new/gclib/gff.cpp 2021-10-04 10:54:52.989309121 -0400
*************** GffLine::GffLine(GffReader* reader, cons
*** 405,411 ****
GMALLOC(dupline, llen+1);
memcpy(dupline, l, llen+1);
skipLine=true; //clear only if we make it to the end of this function
! char* t[9];
int i=0;
int tidx=1;
t[0]=line;
--- 405,411 ----
GMALLOC(dupline, llen+1);
memcpy(dupline, l, llen+1);
skipLine=true; //clear only if we make it to the end of this function
! char* t[9] = {0};
int i=0;
int tidx=1;
t[0]=line;
Ideally, the library should gracefully handle no info being found (this only works if t is zero initialized):
Reproduce
PoC Input: min.gz
Steps to Reproduce:
gzip -d min.gz
./gffread -E min -o out
Output:
Root Cause
https://github.com/gpertea/gclib/blob/8aee376774ccb2f3bd3f8e3bf1c9df1528ac7c5b/gff.cpp#L413-L432
When GCLib reads a GFF line with no info segment, the
char *
att[8]
will not be set, causing it to take on whatever stale value happens to be in that location of the stack. Triggered accidentally, this can cause a segfault due to reading an invalid address here:https://github.com/gpertea/gclib/blob/8aee376774ccb2f3bd3f8e3bf1c9df1528ac7c5b/gff.cpp#L118
However, a maliciously crafted input may be able to place a valid pointer at this location, causing a more severe vulnerability.
Proposed Patch
At a minimum,
t
should be zeroed during initialization:Ideally, the library should gracefully handle no info being found (this only works if
t
is zero initialized):Credit
This bug was detected using AFL and localized using ARCUS.