Unexpected ArrayIndexOutOfBoundsException
in CBORParser
for corrupt String value
#464
Labels
ArrayIndexOutOfBoundsException
in CBORParser
for corrupt String value
#464
The
CBORParser::_finishShortText(int)
method relies on the integer index_inputPtr
to read the next character from the provided input byte array. It takes in an integerlen
to determine how many characters are needed to read from the byte array input. In the method, there is a while loop to read all the needed characters. One of the exit points of the while loop is when the integerend
is reached whereend
is calculated by_inputPtr + len
. Becauselen
is read from the input and could be malformed, a very large len could make theend
variable much larger than the size of the input byte array buffer. This could causeArrayIndexOutOfBoundsException
when the while loop does not exit correctly with a largeend
value. It could also throwArrayIndexOutOfBoundsException
ifinPtr
already pointing at the end ofinputBuf
when entering the while loop. Last but not least, if the providedlen
is negative, theend
value is almost certain to be negative and it results in the same situation as the first case.The suggested fix is to add a check before entering the while loop to ensure the
end
is not larger than the size of theinputBuf
byte array.We found this issue by OSS-Fuzz and it is reported in https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65722.
The text was updated successfully, but these errors were encountered: