Skip to content

ArrayIndexOutOfBoundsException from UTF32Reader.read on invalid input #382

@emilyselwood

Description

@emilyselwood

We are doing some fuzz testing on internal projects and found some input that causes an unexpected exception from JsonParser. While it is throwing an exception and stopping on this, it should probably be some kind of IOException rather than an ArrayIndexOutOfBoundsException.

In our case we are catching the three exception types listed in ObjectMapper.readTree (JsonParseException | JsonProcessingException | IOException) and this managed to escape.

Simple test case follows

public void testInvalidInput() throws IOException {

        byte[] data = {
                0x00,
                0x00,
                0x00,
                0x20,
                (byte) 0xFE,
                (byte) 0xFF,
                0x00,
                0x01,
                (byte) 0xFB
        };

        JsonFactory FACTORY = new JsonFactory();
        JsonParser parser = FACTORY.createParser(data);

        parser.nextToken();


    }

stack trace:

java.lang.ArrayIndexOutOfBoundsException: 9

	at com.fasterxml.jackson.core.io.UTF32Reader.read(UTF32Reader.java:138)
	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._loadMore(ReaderBasedJsonParser.java:243)
	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._skipWSOrEnd(ReaderBasedJsonParser.java:2331)
	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:646)
	at com.fasterxml.jackson.core.io.TestUTF32Reader.testInvalidInput(TestUTF32Reader.java:32)

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