Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4333

ClassCastException when loading PDF

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.12
    • 2.0.13, 3.0.0 PDFBox
    • Parsing
    • None

    Description

      Fuzzing PDF loading with JQF triggered a ClassCastException. All attached files trigger the exception for a different class but are basically the same.

      org.apache.pdfbox.cos.COSArray cannot be cast to org.apache.pdfbox.cos.COSObject
      java.lang.ClassCastException: org.apache.pdfbox.cos.COSArray cannot be cast to org.apache.pdfbox.cos.COSObject
          at org.apache.pdfbox.pdfparser.COSParser.checkPagesDictionary(COSParser.java:2337)
          at org.apache.pdfbox.pdfparser.COSParser.checkPages(COSParser.java:2321)
          at org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:193)
          at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:220)
          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1160)
          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1057)
          ...
      
      

      The Code used for fuzzing is

      PDDocument.load(inputStream)
      

      Throwing an Exception is ok since no other PDF reader I tried is able to load the files. But it should not be an ClassCastException.

      Attachments

        1. ClassCastException COSInteger instead of COSObject
          0.2 kB
          Robin Schimpf
        2. ClassCastException COSName instead of COSObject
          0.2 kB
          Robin Schimpf
        3. ClassCastException COSNull instead of COSObject
          0.2 kB
          Robin Schimpf
        4. ClassCastException COSString instead of COSObject
          0.2 kB
          Robin Schimpf
        5. ClassCastException COSArray instead of COSObject
          0.2 kB
          Robin Schimpf
        6. ClassCastException COSBoolean instead of COSObject
          0.2 kB
          Robin Schimpf
        7. ClassCastException COSFloat instead of COSObject
          0.2 kB
          Robin Schimpf

        Activity

          People

            tilman Tilman Hausherr
            rschimpf Robin Schimpf
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: