[00:00] It seems like every week now we're seeing security incidents happening that would have made mainstream news just a few years ago. The big ones lately have been the North Korean hackers who Trojan whores taffed the JavaScript ecosystem, the OpenAI model that committed a felony to get answers to a [00:14] benchmark, and that Time Anthropic accidentally open-sourced cloud code at 4am via an NPM source map. But sometimes it's good to remember that even before AI, software has always been held together with duct tape and the poverty of open-source maintainers. And there's no better [00:29] example of this than the damage one company managed to do to itself 14 years ago this month with organic human retardedness. In about 45 minutes on a random Wednesday, Knight Capital, who at one time was responsible for 10% of all stock trading happening in the United States, [00:44] lost $440 million and four months later was sold for parts. In today's video, we'll look into what caused the most expensive software bug in history and learn how to lose $10 million in a minute with this one weird trick. It is August 27th, 2026, and you're watching The Code Report. In 2012, [01:00] while the rest of us were planking on gas station roofs and awaiting the Mayan apocalypse, Knight Capital was quietly operating as the biggest market maker on Wall Street as it processed $20 billion in trades every day. If you remember back to the GameStop Robin Hood saga from a few [01:14] years ago Knight Capital was basically the citadel of its time Whenever an ape like you or me would buy a stock from a brokerage like E the brokerage didn actually execute the trade themselves Instead they often pass it off to Knight who would fill the order and pocket the spread [01:28] At its core was a system called SMARS, which was an order router that took large orders and chopped them up into smaller orders to fill them across the market at the best prices. It was fast, reliable, and more importantly, it printed money for over a decade. [01:42] Then, in the summer of 2012, the New York Stock Exchange decided it was sick of watching firms like Knight skim off all the retail orders before they ever reached the actual exchange. So it created something called the Retail Liquidity Program, which was essentially its own version of Knight's business model designed to get orders back with slightly better prices. [02:00] The SEC approved it in June with a go-live date of August 1st. And because Knight was ironically also one of the exchange's biggest customers, they were forced to implement it. So that's what they started to do, and like any large financial institution responsible for the livelihood of hardworking blue-collared Americans, they did it with dignity and grace. [02:18] Just kidding, they did it in the most lazy way possible. At the time, deep in the SMARS codebase was an old feature flag that hadn't been used since 2003, but it was never deleted. Flipping the flag would trigger a test function called PowerPeg which would execute a bunch of buy orders so Knight could watch how a stock price would respond And since the whole point was to push prices around it was designed to buy aggressively at the current market price with zero concern for getting a good deal But when the engineers in 2012 needed to switch on the new retail liquidity program [02:48] rather than create a feature flag, they just reused the old PowerPeg one and swapped out the logic behind it. And they would have gotten away with it if this code was only running on a single server, or if they had any DevOps on the team, or if it hadn't been for those meddling [03:00] kids and their dog, but I assume none of those were true. Back then, their deployment strategy took inspiration from the Pony Express, in that they'd have a guy manually copy code changes to their 8 servers across several days. Unfortunately, while deploying the retail liquidity change, [03:15] they hit one of the two hardest problems in computer science, and only 7 out of the 8 servers got the update. Then, on August 1st, 2012, when Knight flipped the feature flag, 7 of their servers processed orders correctly, while the 8th one woke up PowerPeg from its 9-year hibernation, [03:29] and it got to work on its degen strategy of buying high and selling low. Knight immediately noticed something was up, but as you can imagine, someone who gets themselves into the situation is unlikely to have a good way of getting themselves out of it. [03:41] So they panicked, assumed the problem was in their new code, and rolled back the seven healthy servers, which meant now all eight were running PowerPeg. And to be honest, that feels like a suitable name for what the market was doing to them. In the 45 minutes it took them to figure out the issue and flip the feature flag back they had executed 4 million trades across 154 stocks and were now the proud owner of a new billion position There was even a random penny stock [04:05] called Wizard Software Corporation that went from $3 to $14 for no reason at all. When the dust settled, Knight was down over $440 million and its stock had dropped 75% in two days. [04:17] Four months later, it was acquired by its competitor, Gitko, and in 2017, another financial services firm called Virtue absorb what was left. The good news though, is that we definitely learned our lesson in the software industry, and nothing bad ever happened again. And that's why you need to know about [04:31] HyperAgent, the sponsor of today's video. Maintaining a popular open source date library is mostly just three people drowning in a thousand GitHub issues about daylight savings. So my co-maintainers and I hired a team of agents to keep it alive. When a new issue comes in, [04:45] one agent labels it and reproduces the bug, then hands it off to another that hunts down the fix and opens a draft pull request. They work around the clock, across every time zone we're asleep in, and only ping a human when it's time to actually approve a merge. [04:58] Every maintainer shares the same agents, so once you teach them how your project works, nobody has to teach them twice. And with support for DeepSeek and the top openweight model, even the AI maintaining your open source project can stay open source. [05:11] Try it out and grab your free credits at the link below. This has been The Code Report. Thanks for watching, and I will see you in the next one.