REDHAT-BUG-2516959: High severity Perl DBI vulnerability
DBI versions before 1.652 for Perl allow a heap out-of-bounds write via an unvalidated numeric placeholder that sets the binder counter in preparse.
preparse reserves seven output bytes per input byte, the width of the longest ':p99999' expansion. The ':N' branch parses the number with atoi(src) and assigns it to the binder counter with no range check, so a statement containing ':2147483648' leaves the counter negative (-2147483648 with glibc, where atoi wraps). Each following '?' then expands through sprintf(start, ":p%d", idx++) to ':p-2147483648', 14 bytes with the terminating NUL where the buffer budgets 7. The placeholder limit added in 1.650 tests the counter against 99,999, which a negative counter passes.
Any caller that preparses an untrusted statement into ':pN' style placeholders gets a heap out-of-bounds write that grows with the number of '?' marks following the poisoned placeholder. The '?' and '%s' return styles compare the parsed number against the expected sequence and error out, and are unaffected.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Perl DBIto a version that resolves this vulnerability.Fixed in 1.652
Event History
Frequently Asked Questions
Which applications are realistically exposed?
Applications are exposed if they preparse attacker-controlled SQL statements using the ':pN' placeholder return style. The out-of-bounds write can grow with each '?' placeholder placed after the malicious numeric placeholder.
What input is required to trigger the issue?
An attacker needs to supply a statement containing an oversized numeric placeholder such as ':2147483648', followed by one or more '?' placeholders. The unchecked numeric value can make the internal binder counter negative, causing later expansions to exceed the reserved buffer size.
Are all placeholder return styles affected?
No. The '?' and '%s' return styles validate the parsed number against the expected sequence and reject invalid input; they are unaffected according to the available information.
What can be done if upgrading is not immediately possible?
Avoid preparsing untrusted statements into the ':pN' placeholder style. Where feasible, use the '?' or '%s' return styles, which reject the malformed numeric placeholder sequence described here.