Executive brief
DBD::Pg is a database interface module for Perl that allows applications to connect to and query PostgreSQL databases. A memory allocation bug in the quote_float function causes a heap buffer overflow when quoting special floating-point literals (NaN, Infinity, etc.), which can be triggered by database queries. An attacker could exploit this to crash the application or potentially execute arbitrary code.
Technical details
The vulnerability is a heap out-of-bounds write in the quote_float() function in DBD::Pg 3.21.0, introduced during a rewrite of quote.c. The function allocates insufficient memory (length + 1 bytes) to store quoted special float literals (NaN, Inf, +Inf, -Inf, Infinity, +Infinity, -Infinity), which require length + 3 bytes (opening quote, string content, closing quote, and NULL terminator). Every recognized literal overflows by 2 bytes, writing past the allocated buffer. The vulnerability can be triggered via the $dbh->quote() method with a SQL_NUMERIC type specifier, requiring no special privileges but direct application access to the vulnerable code path. The patch (commit 6d6f47ed) corrects the allocation size in quote.c line 375 from length + 1 to length + 3.
Affected products
- CPAN DBD::Pg 3.21.0
Timeline
- 2026-08-23: disclosed
- 2026-08-23: patched