Just found a dusty old post of mine:
This challenge appeared on an internal alias dedicated to C++. It was issued by Mike Vine, a developer here at Microsoft who agreed to let us share it with the mighty Visual C++ blog readers:
This challenge came from me thinking about a simple bug which could be turned into a security vulnerability, so I thought Id give it a go and try to code a plausibly deniable piece of code which looks innocent but is actually dangerous. I managed to actually go further than that, and produced something, that whilst unlikely, could possibly have come from non-malicious but sloppy coding.
So your challenge is if you choose to accept it analyze the sample code file main.c (attached) and try to find the (fairly obvious) security faux pas and accidental bug which causes the security faux pas to be exploitable.
The 7th Underhanded C Contest is now open.
The goal of the contest is to write code that is as readable, clear, innocent and straightforward as possible, and yet it must fail to perform at its apparent function. To be more specific, it should do something subtly evil. Every year, we will propose a challenge to coders to solve a simple data processing problem, but with covert malicious behavior. Examples include miscounting votes, shaving money from financial transactions, or leaking information to an eavesdropper. The main goal, however, is to write source code that easily passes visual inspection by other programmers.