The crash
NetHack 5 had an integer-truncation bug in its terminal resize code: widths above 32,767 wrapped negative, causing an undersized allocation and an out-of-bounds write. This gave players an on-demand crash, which combined with a save/checkpoint ordering flaw during level transitions to duplicate items, including charged wands of wishing and unique artifacts.
josephthacker.com
Published on josephthacker.com
This is how I used GPT-5.6 Daybreak Blue to find a buffer overflow, crash the game in order to dupe items, and get the high score on the NetHack 5.0 leaderboard.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an integer truncation in the terminal resize routine produced a negative width and an undersized buffer, and the save logic wrote the departing level before updating the global checkpoint, so a crash mid-transition left inconsistent state.
Impact
Players could duplicate items on demand, including charged wands of wishing and unique artifacts, and use this to reach the top of the leaderboard; the text notes the duplication was patched after other players noticed.
What the attacker needed
Access to a NetHack 5 server; ability to resize the terminal; timing the crash during a level change
How it was found
- Resize the terminal to a very large width and back to trigger the crash.
- Drop an item and descend to the next level.
- Pause at the --More-- prompt and trigger the crash.
- Recover the game so the new level file and old global state are combined.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A number meant to hold the width of the terminal window was stored in a small slot, so a very large width wrapped around to a negative value. The game then reserved too little memory for drawing the screen and wrote past the end of it, which crashed the program. Separately, the game saved the new level before updating its overall progress record, so crashing at the right moment made the game believe an item existed twice.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.