CVE-2022-38784 - Integer Overflow or Wraparound

Severity

78%

Complexity

18%

Confidentiality

98%

Poppler prior to and including 22.08.0 contains an integer overflow in the JBIG2 decoder (JBIG2Stream::readTextRegionSeg() in JBIGStream.cc). Processing a specially crafted PDF file or JBIG2 image could lead to a crash or the execution of arbitrary code. This is similar to the vulnerability described by CVE-2022-38171 in Xpdf.

CVSS 3.1 Base Score 7.8. CVSS Attack Vector: local. CVSS Attack Complexity: low. CVSS Vector: (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).

Demo Examples

Integer Overflow or Wraparound

CWE-190

The following image processing code allocates a table for images.


               
...

This code intends to allocate a table of size num_imgs, however as num_imgs grows large, the calculation determining the size of the list will eventually overflow (CWE-190). This will result in a very small list to be allocated instead. If the subsequent code operates on the list as if it were num_imgs long, it may result in many types of out-of-bounds problems (CWE-119).

Integer Overflow or Wraparound

CWE-190

The following code excerpt from OpenSSH 3.3 demonstrates a classic case of integer overflow:


               
}
for (i = 0; i < nresp; i++) response[i] = packet_get_string(NULL);

If nresp has the value 1073741824 and sizeof(char*) has its typical value of 4, then the result of the operation nresp*sizeof(char*) overflows, and the argument to xmalloc() will be 0. Most malloc() implementations will happily allocate a 0-byte buffer, causing the subsequent loop iterations to overflow the heap buffer response.

Integer Overflow or Wraparound

CWE-190

Integer overflows can be complicated and difficult to detect. The following example is an attempt to show how an integer overflow may lead to undefined looping behavior:


               
}
bytesRec += getFromInput(buf+bytesRec);

In the above case, it is entirely possible that bytesRec may overflow, continuously creating a lower number than MAXGET and also overwriting the first MAXGET-1 bytes of buf.

Integer Overflow or Wraparound

CWE-190

In this example the method determineFirstQuarterRevenue is used to determine the first quarter revenue for an accounting/business application. The method retrieves the monthly sales totals for the first three months of the year, calculates the first quarter sales totals from the monthly sales totals, calculates the first quarter revenue based on the first quarter sales, and finally saves the first quarter revenue results to the database.


               
}
return 0;// Variable for sales revenue for the quarter// Calculate quarterly total// Calculate the total revenue for the quarter

However, in this example the primitive type short int is used for both the monthly and the quarterly sales variables. In C the short int primitive type has a maximum value of 32768. This creates a potential integer overflow if the value for the three monthly sales adds up to more than the maximum value for the short int primitive type. An integer overflow can lead to data corruption, unexpected behavior, infinite loops and system crashes. To correct the situation the appropriate primitive type should be used, as in the example below, and/or provide some validation mechanism to ensure that the maximum value for the primitive type is not exceeded.


               
}
...// Calculate quarterly total// Calculate the total revenue for the quarter

Note that an integer overflow could also occur if the quarterSold variable has a primitive type long but the method calculateRevenueForQuarter has a parameter of type short.

Overview

First reported 2 years ago

2022-08-30 03:15:00

Last updated 2 years ago

2022-10-28 20:08:00

Affected Software

freedesktop Poppler

References

https://poppler.freedesktop.org/releases.html

https://github.com/jeffssh/CVE-2021-30860

https://gist.github.com/zmanion/b2ed0d1a0cec163ecd07d5e3d9740dc6

https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/1261/diffs?commit_id=27354e9d9696ee2bc063910a6c9a6b27c5184a52

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-38171

https://poppler.freedesktop.org/releases.html

Release Notes, Vendor Advisory

https://github.com/jeffssh/CVE-2021-30860

Third Party Advisory

https://gist.github.com/zmanion/b2ed0d1a0cec163ecd07d5e3d9740dc6

Patch, Third Party Advisory

https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/1261/diffs?commit_id=27354e9d9696ee2bc063910a6c9a6b27c5184a52

Patch, Vendor Advisory

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-38171

Third Party Advisory

[oss-security] 20220902 JBIG2 integer overflow fixed in Xpdf 4.04, Poppler 22.09.0

Mailing List, Third Party Advisory

DSA-5224

FEDORA-2022-f7b375eae8

FEDORA-2022-51b27699ce

[debian-lts-announce] 20220925 [SECURITY] [DLA 3120-1] poppler security update

GLSA-202209-21

DSA-5224

Third Party Advisory

FEDORA-2022-f7b375eae8

Mailing List, Third Party Advisory

FEDORA-2022-51b27699ce

Mailing List, Third Party Advisory

[debian-lts-announce] 20220925 [SECURITY] [DLA 3120-1] poppler security update

Third Party Advisory

GLSA-202209-21

Third Party Advisory

FEDORA-2022-f79aa2bae9

FEDORA-2022-fcb3b063a6

https://github.com/zmanion/Vulnerabilities/blob/main/CVE-2022-38171.md

https://www.cve.org/CVERecord?id=CVE-2022-38171

FEDORA-2022-f8ec1c06a3

FEDORA-2022-f79aa2bae9

Mailing List, Third Party Advisory

FEDORA-2022-fcb3b063a6

Mailing List, Third Party Advisory

https://github.com/zmanion/Vulnerabilities/blob/main/CVE-2022-38171.md

Exploit, Third Party Advisory

https://www.cve.org/CVERecord?id=CVE-2022-38171

Third Party Advisory

FEDORA-2022-f8ec1c06a3

Mailing List, Third Party Advisory

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.