I Found My First CVE by Trying to Understand Someone Else’s Bug | The story of CVE-2026–73194
A memory-safety flaw in Perl's DBI module allowed a crafted SQL statement with an oversized named placeholder to corrupt an internal counter, causing a heap buffer overflow. An attacker could crash the application, and potentially worse, if they can influence the text of a prepared SQL statement.
Published on medium.com
Cybersecurity
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
DBI is the Database Interface module for Perl. It sits between Perl code and whatever database the code talks to, MySQL, Oracle, Postgres or anything else. When a Perl program writes a SQL query using placeholders, either a plain question mark or a named one such as :1, DBI is the layer that turns those placeholders into something the database driver understands.
The function at the centre of this story is preparse. Its job is to take a SQL statement containing placeholders and rewrite every one of them into a standard numbered form, :p1, :p2 and so on, before handing the statement to the driver. It is old, stable code that a great deal of Perl software still depends on.

The author found the bug while reading the fixes for two earlier CVEs in the same function, and the result was assigned CVE-2026-73194.
Setup
The work described here is source review plus a standalone harness, not a live target. The pieces involved:
- The DBI source, with the real allocation line and the real vulnerable branch copied out unmodified.
- A small standalone C program,
02_preparse_overflow_repro.c, into which those lines were dropped. The only substitution was replacing Perl's internal memory functions with a plain, equivalently sizedmalloc. Both are flat boxes of memory with no built in bounds checking, so the substitution does not change what is being tested. - AddressSanitizer, used at compile time, to watch every memory read and write and flag the moment something writes outside its allocation.
- A second, identical harness with one change: a range check on the parsed placeholder number before it is trusted.
No accounts, roles or remote endpoints are involved. The precondition for the bug to matter in a real deployment is that outside input can influence the text of a SQL statement before it is prepared.
Finding it
The starting point was CVE-2026-10879, a bug in preparse that had already been reported and fixed. When preparse rewrites a question mark into its numbered form it has to set aside memory for the new text. The original code budgeted 3 characters per placeholder, enough for something like :p9. That is fine for the first 9 placeholders, but placeholder 10 needs :p10, which is 4 characters, and placeholder 100 needs 5. The buffer never grew to match, so a statement with more than 9 placeholders wrote past the end of its allocation. That was fixed in DBI 1.648.
The fix was not complete. A second CVE, CVE-2026-14739, followed shortly after: the first fix still did not account for an extreme number of placeholders, somewhere around 1.2 million of them, which could still overflow the corrected buffer. The follow up in DBI 1.650 closed that gap by rejecting anything over 99999 placeholders outright.
Two fixes to the same function in the same year prompted a close reading of the actual fix commits and their diffs, line by line, to understand what assumption the code was resting on. Both fixes protected only one path into the function, the path where preparse counts question marks one at a time. There was a second, completely different way the same counter could be corrupted, and neither fix had touched it.
Exploitation
Step 1: understand the allocation promise
After both earlier fixes, the line that decides how much memory to set aside for the rewritten statement was:
new_stmt_sv = newSV(strlen(statement) * 7 + 16)
The length of the original query is multiplied by 7, plus a little extra room, and that is the size of the box the new version is written into. The 7 comes from the longest placeholder DBI expects to write, something like :p99999, which is 7 characters. The code is promising itself that it will never write more than 7 extra characters for any single placeholder, and everything downstream trusts that promise without checking it again.
Step 2: find the branch that trusts a number
The problem sits in the branch that handles named placeholders such as :1 or :42:
else if (isDIGIT(*src)) { const int pln = atoi(src); style = “:1”; if (PS_return(DBIpp_ph_cn)) { idx = pln; *dest++ = ‘p’; while(isDIGIT(*src)) *dest++ = *src++; } …}
When DBI sees digits after a colon, it reads them with atoi, which turns the text into an integer. Whatever number comes out is trusted completely and assigned straight to idx, the same counter that tracks how many placeholders have been written so far, and the exact counter both earlier fixes were built around protecting. Nothing asks whether the number is reasonable.
Step 3: confirm the integer behaviour in isolation
A C int, the type atoi returns, can only count up to 2147483647. One digit past that limit, the number wraps around into a huge negative value instead of erroring. The author tested this separately from DBI:
atoi(“2147483648”) = -2147483648 -> sprintf width if used as idx: 13 chars (‘:p-2147483648’) guard(idx>=99999)? BYPASSEDatoi(“99999999999999999999999”) = -1 -> sprintf width if used as idx: 4 chars (‘:p-1’) guard(idx>=99999)? BYPASSEDatoi(“4294967296”) = 0 -> sprintf width if used as idx: 3 chars (‘:p0’) guard(idx>=99999)? BYPASSED
A ten digit string that looks entirely ordinary to a human, :2147483648, comes back as negative two billion one hundred forty seven million and change. No error, no warning, just a confidently wrong number. Other digit strings produce their own nonsense, zero or small negatives, and all of them slip past the same guard.
Step 4: walk through the guard
The guard that the two earlier CVEs built together, meant to stop the counter growing past what the buffer can hold, is:
if (idx >= 99999) { char buf[99]; sprintf(buf, “preparse found more than 99999 ‘?’ placeholders. Limit exceeded.”); set_err_char(dbh, imp_xxh, “1”, 1, buf, 0, “preparse”); return &PL_sv_undef;}
It asks one question only: is the number too high. It never considers whether the number might be impossibly low. A huge negative number is always less than 99999, so it walks straight through, every time.
Step 5: reach the write
The line that does the writing is:
sprintf(start,”:p%d”, idx++);
Normally this writes something small such as :p1 or :p42, which fits inside the 7 characters per placeholder the buffer was sized for. With idx poisoned to negative two billion one hundred forty seven million, the same line has to write :p-2147483648, which is 13 characters. It writes that oversized value again for every question mark that follows, because idx keeps incrementing from the broken starting point. Every extra character lands past the edge of the allocation.
Step 6: reproduce against the real code
Testing against a rewritten copy of the code proves little, because a subtle difference means testing your own mistake rather than the vulnerability. The real allocation line and the real vulnerable branch were therefore copied unmodified into the standalone harness, with Perl's memory functions swapped for an equivalent malloc, and compiled with AddressSanitizer. The result:
==526==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x511000000129WRITE of size 14 at 0x511000000129 thread T0 #0 in vsprintf #1 in sprintf #2 in main 02_preparse_overflow_repro.c:76
0x511000000129 is located 0 bytes after 233-byte region [0x511000000040,0x511000000129)allocated by thread T0 here: #1 in main 02_preparse_overflow_repro.c:57
The tool catches the exact moment the sprintf line writes one byte past the end of the region it was given, pointing at the real, unmodified line from DBI's source.
Step 7: show the fix closes it
A second harness, identical except that the parsed placeholder number is checked to fall between 1 and 99999 before being trusted into idx, was run with the same malicious input:
[control] statement = “:2147483648????????????????????” (len=31, 20 ‘?’ marks)[control] placeholder number -2147483648 out of range — rejected as intended (fix engaged).
The input is turned away cleanly, with no crash and nothing written outside the buffer. Legitimate use was checked too, with a query mixing a named placeholder and question marks:
[legit] input: select * from t where a=:1 and b=? and c=?[legit] output: select * from t where a=:p1 and b=:p1 and c=:p2
That still behaves exactly as documented, so the fix stops the attack without touching what was already correct.
Root cause
The mistake is trusting an attacker influenced number without a range check. atoi silently wraps on overflow, and the resulting negative value is assigned to the placeholder counter idx. The guard added by the two earlier fixes only tests the upper bound, idx >= 99999, so a negative value passes. The buffer sizing assumes at most 7 characters per placeholder, and the poisoned counter breaks that assumption in a single step rather than gradually.
This is a different category from the two earlier bugs. CVE-2026-10879 and CVE-2026-14739 were about not setting aside enough room, overflowing by a fixed, predictable amount because the counter only moved upward one at a time. Here DBI writes content it was never supposed to write, into memory it was never given permission to touch, using a value the attacker has partial influence over, and jumps straight to a large overflow. A write past the edge of a buffer is generally treated as more serious than simply running out of buffer, because the first can sometimes be steered and the second usually just crashes predictably.
Impact
The bug is reachable by any application that lets outside input influence the text of a SQL statement before it is prepared. Not the bind values, which DBI's placeholders already protect against, but the statement text itself, for example dynamically built queries or template assembled SQL. That is a narrower situation than classic SQL injection, but a real one.
What is confirmed is a genuine memory safety write past a buffer, capable at minimum of crashing whatever program hits it. How far it could be pushed with more engineering behind it was not investigated. DBI's maintainer rated the bug as low risk, which the author considers a fair assessment given how narrow the trigger condition is.
Fix
The fix landed in DBI 1.652, alongside a separate fix limiting how large a single statement can be during preparsing. The report, harness and AddressSanitizer output were sent to DBI's maintainer, HMBRAND, who fixed the issue without pushback.
At code level the change is small: check that the parsed number is actually reasonable, somewhere between 1 and 99999, before trusting it into anything else. The author also suggests going a step further and replacing atoi with something like strtol, which can report that a number was too big to fit instead of silently wrapping into nonsense.
At process level, this is the kind of bug that fuzzing, deliberately feeding a program weird, oversized or boundary pushing input, tends to surface quickly. Parsing code that looks too simple to break is usually the code nobody tests that way. At review level, when a function has already needed two fixes for the same underlying assumption, every place that assumption could break deserves checking, not just the path that was reported.
Variants to test
- Look for other
atoicalls whose result feeds a counter, an index or a length. A positive result is a value that can be made negative or zero with a digit string just pastINT_MAX, and that then passes a one sided upper bound check. - Audit guards that only test an upper bound, such as
if (idx >= LIMIT). A positive result is any path where a negative or zero value reaches the same variable and is used in a size calculation or format string. - Check buffer sizing formulas that assume a maximum width per element, like
strlen(x) * 7 + 16. A positive result is an input that makes a single element wider than the assumed width, especially through a signed value rendered with%d. - Re-read the fix commits for a function that has already been patched more than once. A positive result is a second entry path into the same variable that none of the patches touched.
- Reproduce with the real source lines in a standalone harness under AddressSanitizer rather than a rewrite. A positive result is an ASan report naming the exact line, with the write landing just past the allocated region.
- Test the proposed fix with both malicious and legitimate inputs. A positive result is the malicious input rejected cleanly and normal placeholder rewriting, including mixed named and question mark placeholders, unchanged.
What happened, in plain words
A security researcher was scrolling through a list of recently published software bugs late at night, the way some people scroll through news or social media. One entry caught his eye: a small bug in a piece of software called DBI, in a function called preparse. He read the summary, thought it was interesting, and decided to actually read the code that had been fixed. While reading it closely, he noticed that the fixes had only closed one way into the problem, and that a second way was still open. He tested that second way, confirmed it was a real bug, reported it, and it now has its own identifier, CVE-2026-73194. This article walks through the whole story slowly, explaining every term along the way.

What DBI is, and why old code matters
If you have never used the programming language Perl, the name DBI means nothing, and that is fine. DBI stands for Database Interface. It is a library, meaning a collection of ready made code that other programs can use, for the Perl language. It sits between a Perl program and a database, which is an organised store of data such as MySQL, Oracle or Postgres. When a Perl program wants to ask the database a question, it writes a SQL query, which is the standard language for talking to databases, and DBI is the layer that carries that query to the database and brings the answer back.
A key idea here is the placeholder. Instead of typing a value directly into a query, a programmer writes a marker where the value should go, and the real value is supplied separately. The marker is either a plain question mark ? or a named one such as :1. This is a safety measure: it keeps user supplied values from being confused with the structure of the query. DBI's job includes turning those placeholders into a form the database driver, the piece of software that actually speaks to a particular database, can understand.
The function at the centre of the story is preparse. Its job is to take a SQL statement containing placeholders and rewrite every one of them into a standard numbered form, :p1, :p2 and so on, before handing the statement to the driver. It is old, stable code that a great deal of Perl software still depends on.
The author makes a point about why this kind of code is worth looking at. New and fashionable frameworks get audited constantly, meaning people examine them for mistakes. Boring modules that have been stable for twenty years get looked at once, trusted, and then mostly left alone. Bugs do not need a complicated system to hide in. They just need a place nobody is checking anymore.
Reading the fix, not just the bug
The starting point was an earlier bug, CVE-2026-10879, which had already been reported and fixed. A CVE is a public identifier given to a known security flaw, so that people can talk about it unambiguously. To understand this bug, you need one more idea: a buffer. A buffer is a reserved block of computer memory, like a box of a fixed size set aside to hold something. When a program needs to build a new piece of text, it first sets aside a box big enough for the result, then writes into it. If it writes more than the box can hold, the extra characters spill past the edge into neighbouring memory. That is called a buffer overflow, and it is dangerous because the spilled data can corrupt whatever else lives there.
When preparse rewrites a question mark into its numbered form, it has to set aside memory for the new text. The original code budgeted 3 characters per placeholder, enough for something like :p9. That is fine for the first 9 placeholders, but placeholder number 10 needs :p10, which is 4 characters, and placeholder 100 needs 5. The box never grew to match, so a statement with more than 9 placeholders wrote past the end of its allocation. That was fixed in DBI version 1.648.
The fix was not complete. A second CVE, CVE-2026-14739, followed shortly after: the first fix still did not account for an extreme number of placeholders, somewhere around 1.2 million of them, which could still overflow the corrected buffer. The follow up in DBI 1.650 closed that gap by rejecting anything over 99999 placeholders outright.
Two fixes to the same function in the same year prompted the author to do something most people skip: he pulled up the actual fix commits, meaning the recorded changes made to the code, and read the diffs line by line. A diff is simply a comparison showing exactly what was added and what was removed. He wanted to understand what assumption the code was resting on, not just the headline version of the bug. Both fixes protected only one path into the function, the path where preparse counts question marks one at a time. There was a second, completely different way the same counter could be corrupted, and neither fix had touched it.
Step 1: understand the allocation promise
After both earlier fixes, the line that decides how much memory to set aside for the rewritten statement was:
new_stmt_sv = newSV(strlen(statement) * 7 + 16)
Line by line in plain words. strlen(statement) measures how many characters long the original query is. That length is multiplied by 7, and 16 is added as a little extra room. newSV is the Perl function that creates a new piece of memory of that size. So the whole line says: take the length of your original query, multiply it by 7, add a little extra, and that is how big a box I will set aside to write the new version into.
The number 7 is not random. It comes from the longest placeholder DBI expects to write, something like :p99999, which is 7 characters. The code is making a promise to itself: I will never write more than 7 extra characters for any single placeholder. Everything downstream trusts that promise without checking it again. Think of it like booking a table for a fixed number of guests and assuming nobody will bring a plus one: the whole evening's plan rests on that assumption, and nobody re-checks it at the door.
Step 2: find the branch that trusts a number
The problem sits in the branch that handles named placeholders such as :1 or :42:
else if (isDIGIT(*src)) { const int pln = atoi(src); style = “:1”; if (PS_return(DBIpp_ph_cn)) { idx = pln; *dest++ = ‘p’; while(isDIGIT(*src)) *dest++ = *src++; } …}
Line by line. isDIGIT(*src) checks whether the next character is a digit, a number from 0 to 9. If it is, atoi(src) is called. atoi stands for ascii to integer: it takes a piece of text made of digits and turns it into an actual number the computer can do arithmetic with. The result is stored in pln. Then idx = pln copies that number into idx, which is the counter that tracks how many placeholders have been written so far. *dest++ = 'p' writes the letter p into the output, and the while loop copies the remaining digits across.
The important part is that whatever number comes out of atoi is trusted completely and assigned straight to idx, the exact counter both earlier fixes were built around protecting. Nothing asks whether the number is reasonable. It is like a receptionist who accepts whatever name a visitor gives, without checking it against any list.
Step 3: confirm the integer behaviour in isolation
A C int, the type of number atoi returns, is a fixed size container for whole numbers. It can only count up to 2147483647. One digit past that limit, the number wraps around into a huge negative value instead of erroring. This is called an integer overflow, and it is like a car odometer that rolls from 99999 back to 00000, except here it rolls into negative territory. The author tested this separately from DBI, just to see it happen with his own eyes:
atoi(“2147483648”) = -2147483648 -> sprintf width if used as idx: 13 chars (‘:p-2147483648’) guard(idx>=99999)? BYPASSEDatoi(“99999999999999999999999”) = -1 -> sprintf width if used as idx: 4 chars (‘:p-1’) guard(idx>=99999)? BYPASSEDatoi(“4294967296”) = 0 -> sprintf width if used as idx: 3 chars (‘:p0’) guard(idx>=99999)? BYPASSED
Line by line. The first line feeds the ten digit string 2147483648 to atoi and gets back -2147483648, a huge negative number. If that number were used as the counter, the text written would be :p-2147483648, which is 13 characters. The guard, the safety check that rejects numbers of 99999 or more, is marked BYPASSED, meaning it lets the value through. The second line feeds a very long string of nines and gets back -1, producing :p-1, 4 characters, again bypassing the guard. The third line feeds 4294967296 and gets back 0, producing :p0, 3 characters, again bypassing the guard.
A ten digit string that looks entirely ordinary to a human, :2147483648, comes back as negative two billion one hundred forty seven million and change. No error, no warning, just a confidently wrong number. Other digit strings produce their own nonsense, zero or small negatives, and all of them slip past the same guard.
Step 4: walk through the guard
The guard that the two earlier CVEs built together, meant to stop the counter growing past what the buffer can hold, is:
if (idx >= 99999) { char buf[99]; sprintf(buf, “preparse found more than 99999 ‘?’ placeholders. Limit exceeded.”); set_err_char(dbh, imp_xxh, “1”, 1, buf, 0, “preparse”); return &PL_sv_undef;}
Line by line. if (idx >= 99999) asks one question only: is the counter at or above 99999. If it is, a small text buffer buf of 99 characters is created, a message is written into it with sprintf, saying that more than 99999 placeholders were found and the limit was exceeded. set_err_char records that error against the database handle, and return &PL_sv_undef stops the function and returns an undefined value, meaning no result. The check never considers whether the number might be impossibly low. A huge negative number is always less than 99999, so it walks straight through, every time. The lock was built to stop people coming in the front door with too many boxes, and nobody thought to check the side door.
Step 5: reach the write
The line that does the writing is:
sprintf(start,”:p%d”, idx++);
Line by line. sprintf builds a piece of text and writes it into memory starting at start. The format ":p%d" means: write a colon, then a p, then a whole number in decimal. idx++ supplies that number and then increases the counter by one, ready for the next placeholder. Normally this writes something small such as :p1 or :p42, which fits inside the 7 characters per placeholder the buffer was sized for. With idx poisoned to negative two billion one hundred forty seven million, the same line has to write :p-2147483648, which is 13 characters. It writes that oversized value again for every question mark that follows, because idx keeps incrementing from the broken starting point. Every extra character lands past the edge of the allocation. That is the overflow.
Step 6: reproduce against the real code
Testing against a rewritten copy of the code proves little, because a subtle difference means testing your own mistake rather than the vulnerability. It is like testing a lock by building your own copy of it: if your copy is slightly different, a successful break tells you nothing about the real lock. The real allocation line and the real vulnerable branch were therefore copied unmodified into a standalone harness, meaning a small separate program built just to exercise the code, with Perl's memory functions swapped for an equivalent malloc. malloc is the standard C function for reserving a block of memory. Both are flat boxes of memory with no built in bounds checking, so the substitution does not change what is being tested.
The harness was compiled with AddressSanitizer, a tool that watches every single memory read and write while a program runs and immediately flags the exact moment something writes outside the space it was given. The result:
==526==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x511000000129WRITE of size 14 at 0x511000000129 thread T0 #0 in vsprintf #1 in sprintf #2 in main 02_preparse_overflow_repro.c:76
Line by line. ERROR: AddressSanitizer: heap-buffer-overflow is the tool announcing that a write went past the end of a block of memory. The address 0x511000000129 is the exact memory location involved. WRITE of size 14 means 14 bytes were written in one go. thread T0 says which thread of execution did it. The numbered lines below, #0 in vsprintf, #1 in sprintf, #2 in main, are the call stack: the chain of function calls that led to the write, ending at line 76 of the file 02_preparse_overflow_repro.c.
0x511000000129 is located 0 bytes after 233-byte region [0x511000000040,0x511000000129)allocated by thread T0 here: #1 in main 02_preparse_overflow_repro.c:57
Line by line. This second report explains where the memory came from. The address being written to sits 0 bytes after a region of 233 bytes, which starts at 0x511000000040 and ends at 0x511000000129. In other words, the write landed exactly one byte past the end of the box. The region was allocated at line 57 of the same file. The tool catches the exact moment the sprintf line writes one byte past the end of the region it was given, pointing at the real, unmodified line from DBI's source. Not a simulation, not a guess.
Step 7: show the fix closes it
Finding a bug is one thing. Showing that a fix genuinely closes it, without breaking anything that was working correctly before, is the part people skip more often than they should. A second harness, identical except that the parsed placeholder number is checked to fall between 1 and 99999 before being trusted into idx, was run with the same malicious input:
[control] statement = “:2147483648????????????????????” (len=31, 20 ‘?’ marks)[control] placeholder number -2147483648 out of range — rejected as intended (fix engaged).
Line by line. The [control] label marks this as the test with the fix in place. The statement being fed in is :2147483648????????????????????, which is 31 characters long and contains 20 question marks. The second line reports that the placeholder number -2147483648 is out of range and was rejected as intended, with the fix engaged. The input is turned away cleanly, with no crash and nothing written outside the buffer.
Legitimate use was checked too, with a query mixing a named placeholder and question marks:
[legit] input: select * from t where a=:1 and b=? and c=?[legit] output: select * from t where a=:p1 and b=:p1 and c=:p2
Line by line. The [legit] label marks this as a normal, harmless query. The input asks the database to select everything from a table called t where column a equals the first placeholder, column b equals a question mark placeholder, and column c equals another question mark placeholder. The output shows the placeholders rewritten into numbered form: :1 becomes :p1, the first ? becomes :p1, and the second ? becomes :p2. That still behaves exactly as documented, so the fix stops the attack without touching what was already correct.
Why this one is worse than the two before it
CVE-2026-10879 and CVE-2026-14739 were both about DBI not setting aside enough room, running out of space in a predictable, bounded way. That is a real problem, but a fairly contained one: the buffer overflows by a fixed, predictable amount because the question mark counter only ever moves upward, one at a time. Think of a suitcase that is slightly too small, so the last item always sticks out by the same amount.
This one is a different category entirely. It is not about running out of room. It is about DBI writing content it was never supposed to write, into memory it was never given permission to touch, using a value an attacker has partial influence over, and jumping straight to a large overflow in one step instead of growing into it gradually. A write past the edge of a buffer is generally treated as more serious than simply running out of buffer, because the first can sometimes be steered, and the second usually just crashes predictably.
What this actually means for someone using DBI
The bug is reachable by any application that lets outside input influence the text of a SQL statement before it is prepared. Not the bind values, which are the actual data values supplied for the placeholders and which DBI's placeholders already protect against, but the statement text itself, for example dynamically built queries or template assembled SQL. That is a narrower situation than classic SQL injection, the well known attack where user input is smuggled into a query and changes its meaning, but a real one.
What is confirmed is a genuine memory safety write past a buffer, capable at minimum of crashing whatever program hits it. How far it could be pushed with more engineering behind it was not investigated. DBI's maintainer rated the bug as low risk, which the author considers a fair assessment given how narrow the trigger condition is. He says plainly that he would rather report that honestly than inflate it for effect.
How a bug like this gets prevented
At code level the change is small: check that the parsed number is actually reasonable, somewhere between 1 and 99999, before trusting it into anything else. The author also suggests going a step further and replacing atoi with something like strtol, which can report that a number was too big to fit instead of silently wrapping into nonsense. strtol is a C function that converts text to a number and can tell you when the conversion failed.
At process level, this is the kind of bug that fuzzing tends to surface quickly. Fuzzing means deliberately feeding a program weird, oversized or boundary pushing input to see what breaks. Parsing code that looks too simple to break is usually the code nobody tests that way, because it looks harmless.
At review level, when a function has already needed two fixes for the same underlying assumption, every place that assumption could break deserves checking, not just the path that was reported. The author did not do anything clever to find this. He just kept reading after most people would have stopped.
The maintainer
The report, harness and AddressSanitizer output were sent to DBI's maintainer, who goes by HMBRAND. A maintainer is the person responsible for looking after a piece of open source software. They rated the bug as low risk, and the author thinks they were probably right to. But they fixed it anyway, without pushback, without treating the report as an inconvenience. The fix landed in DBI 1.652, alongside a separate fix limiting how large a single statement can be during preparsing. That mattered to the author more than he expected: it is easy to assume maintainers will be defensive about someone finding a hole in code they have maintained for years, and this one was not.
Coming back to that night
The author keeps thinking about how ordinary the whole thing felt while it was happening. He was not trying to find a CVE that night. He was scrolling through a list, half tired, and something small caught his attention for no reason he could really explain, other than that it seemed interesting. Everything after that was just following that interest a little further than most people would bother to: reading the actual diffs instead of the summary, asking what assumption the code was resting on, noticing the one thing that had not been checked.
His advice to someone who has not found their first bug yet is deliberately small. You do not need the newest, flashiest codebase. You do not need a plan. You need to be a little bit more patient than the two fixes that came before you, and willing to keep reading after the point where it would be easier to stop. This was not a critical, headline grabbing bug, and that is fine. Your first one does not have to be huge to matter. It just has to be real, and it just has to be yours.
Glossary
- AddressSanitizer: a tool that watches every memory read and write while a program runs and reports the exact moment something writes outside the space it was given.
- Allocation: a block of memory reserved for a program to use, like a box of a fixed size.
atoi: a C function that turns text made of digits into a whole number, without reporting when the number is too big to fit.- Bind values: the actual data values supplied separately for the placeholders in a query, as opposed to the query text itself.
- Buffer: a reserved block of memory used to hold data while a program works on it.
- Buffer overflow: writing more data than a buffer can hold, so the extra spills past its edge into neighbouring memory.
- Call stack: the chain of function calls that led to a particular point in a program.
- Commit: a recorded change to a codebase, kept in its history.
- CVE: a public identifier given to a known security flaw so people can refer to it unambiguously.
- Database: an organised store of data, such as MySQL, Oracle or Postgres.
- Database driver: the piece of software that actually speaks to a particular kind of database.
- DBI: the Database Interface library for Perl, which sits between Perl code and a database.
- Diff: a comparison showing exactly what was added and removed between two versions of code.
- Fuzzing: deliberately feeding a program weird, oversized or boundary pushing input to see what breaks.
- Harness: a small separate program built to exercise a specific piece of code in isolation.
- Heap: the area of memory a program uses for blocks it reserves at runtime.
- Integer overflow: when a whole number grows past the largest value its fixed size container can hold and wraps around, often into a negative number.
- Library: a collection of ready made code that other programs can use.
malloc: the standard C function for reserving a block of memory.- Maintainer: the person responsible for looking after a piece of open source software.
- Memory safety: the property that a program only reads and writes memory it is allowed to touch.
- Perl: a programming language, widely used for text processing and system work.
- Placeholder: a marker in a query, such as
?or:1, where a value will be supplied separately. preparse: the DBI function that rewrites placeholders into a standard numbered form before the query reaches the driver.- Query: a request for data or an action sent to a database, written in SQL.
- SQL: the standard language for talking to databases.
- SQL injection: an attack where user input is smuggled into a query and changes its meaning.
sprintf: a C function that builds a piece of text from a format and values and writes it into memory.strtol: a C function that converts text to a number and can report when the conversion failed.- Thread: a single path of execution within a program.