Most of those security bugs have been found by using http://lcamtuf.coredump.cx/afl/ for fuzzing the config parser of NetHack. Also read the hilarious account how neglecting the integer range of parsing a number lead to a config that gives you an almost invincible character from the start: https://dpmendenhall.blogspot.com/2020/03/nethack-366-or-how...
In short, there’s plenty of ways to die in NetHack!