CVE-2026-134847
Patch Available.
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
The PostgreSQL JDBC Driver (pgJDBC) is the open-source JDBC driver that lets Java programs connect to a PostgreSQL database using standard, database-independent Java code. It is a pure Java (Type 4) driver that speaks the PostgreSQL native network protocol. It is published to Maven Central as org.postgresql:postgresql, and Spring Boot 2.7 manages its 42.3 line.
A denial of service vulnerability (CVE-2026-134847) has been identified in the PostgreSQL JDBC Driver's binary encoding of BigDecimal parameters, which allows attackers who supply a decimal number that the application parses to keep a thread busy for minutes with a short input. The same flaw truncates the number's weight and scale to 16 bits, so a value outside the range of the binary numeric format is stored as a different number without an error, and a tiny value can pass a range check and be stored as a large one.
Per OWASP: The Denial of Service (DoS) attack is focused on making a resource (site, application, server) unavailable for the purpose it was designed.
This issue affects multiple versions of the PostgreSQL JDBC Driver.
Details
Module Info
- Product: PostgreSQL JDBC Driver
- Affected packages:
org.postgresql:postgresql - Affected versions: >=42.3.0 <42.7.15
- GitHub repository: https://github.com/pgjdbc/pgjdbc
- Published packages: https://central.sonatype.com/artifact/org.postgresql/postgresql
- Package manager: Maven
- Fixed in:
- OSS PostgreSQL JDBC Driver 42.7.15
- NES for PostgreSQL JDBC Driver v42.3.13
Vulnerability Info
This Medium-severity vulnerability is found in the org.postgresql:postgresql package in multiple versions of the PostgreSQL JDBC Driver.
Binary transfer is on by default: Oid.NUMERIC is in the driver's default set of types sent in binary, so PgPreparedStatement.setBigDecimal() (and setObject() with a BigDecimal) hands the value straight to ByteConverter.numeric(BigDecimal):
public void setBigDecimal(@Positive int parameterIndex, @Nullable BigDecimal x)
throws SQLException {
if (x != null && connection.binaryTransferSend(Oid.NUMERIC)) {
final byte[] bytes = ByteConverter.numeric(x);
bindBytes(parameterIndex, bytes, Oid.NUMERIC);
return;
}
setNumber(parameterIndex, x);
}The PostgreSQL binary numeric format holds a 16-bit weight (the number of base-10000 digit groups before the decimal point) and a 14-bit display scale. ByteConverter.numeric(BigDecimal) takes the scale from nbr.scale() without checking it, computes the weight from it, and writes both with ByteConverter.int2(), which keeps only the low 16 bits:
public static byte[] numeric(BigDecimal nbr) {
final PositiveShorts shorts = new PositiveShorts();
BigInteger unscaled = nbr.unscaledValue().abs();
int scale = nbr.scale();
...
} else {
final BigInteger[] split = unscaled.divideAndRemainder(tenPower(scale));
...
//0 based number of 4 decimal digits (i.e. 2-byte shorts) before the decimal
ByteConverter.int2(bytes, idx, weight);
...
//number of digits after the decimal
ByteConverter.int2(bytes, idx, Math.max(0, scale));A BigDecimal whose weight or scale does not fit therefore wraps around into a different, valid binary numeric, and the server stores that value instead of reporting a numeric overflow. For 999999.99e-262144 the scale 262146 is written as 2 and the weight -65535 as 1, so the server receives 999999.99. An application that range-checks a parsed BigDecimal before binding it can accept a tiny value that is then stored as a large one.
Before any of these bytes are written, the encoder also calls tenPower(scale), which falls back to BigInteger.TEN.pow(scale) for large exponents. An attacker-supplied value with a huge scale, such as 1e-200000000, makes the driver build a number with hundreds of millions of digits, which keeps the calling thread busy for minutes per request.
Steps to Reproduce
1. Connect to any PostgreSQL server with an affected driver version and the default connection settings (binary transfer enabled).
2. Bind an out-of-range BigDecimal and read the value back:
PreparedStatement ps = conn.prepareStatement("SELECT ?::numeric");
ps.setBigDecimal(1, new BigDecimal("999999.99e-262144"));
ResultSet rs = ps.executeQuery();
rs.next();
System.out.println(rs.getBigDecimal(1)); // prints 999999.99 instead of failing with a numeric overflow error3. Bind new BigDecimal("1e-200000000") the same way and observe that the call does not return for minutes while one CPU core is saturated.
Mitigation
The PostgreSQL JDBC Driver's security policy ships security fixes by default only for the latest 42.x release line and for 42.2.x, and for other versions only upon request. Upstream has made no 42.3.x release since 42.3.10 (March 2024), so no 42.3.x release is available to address this issue. For more information, see here.
Users of the affected components should apply one of the following mitigations:
- Upgrade affected applications to a currently supported release of the PostgreSQL JDBC Driver that contains the fix.
- Leverage a commercial support partner like HeroDevs for post-EOL security support.
Credits
- Anthropic OSS Scanner (finder)