Manipulated inline images can force PyPDF2 into an infinite loop #329
Labels
is-bug
From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF
nf-performance
Non-functional change: Performance
nf-security
Non-functional change: Security
When you try to get the content stream of this attached PDF, PyPDF2 will end up in an infinite loop. So this is probably a security issue because it might be possible to denial-of-service applications using PyPDF2.
The reason is that the last while-loop in ContentStream._readInlineImage only terminates when it finds the
EI
token, but never actually checks if the stream has already ended. So it's as simple as adding a (broken) inline image that doesn't have anEI
token at all, like the attached PDF.You can see the infinite loop by running this test script with the attached PDF:
I will soon prepare a pull request that fixes this issue.
The text was updated successfully, but these errors were encountered: