2008 Underhanded C Contest Officially Open
Xcott Craver writes "The 2008 Underhanded C Contest has just opened. Every year, contestants are asked to write a simple, innocent, readable C program that appears to perform an innocent task — but implements some non-obvious evil behavior. This year's challenge: redact blocks from an image, but do it so that the excised pixels can somehow be retrieved. We also have listed the winners of last year's contest, which was to write a simple encryption utility that mysteriously and undetectably fails between 1 percent and 0.1 percent of the time. The winning entry is truly impressive."
We discussed the first of these contests in 2005.
I'm sure it would be nearly impossible to hide the evil code here, because anything that isn't a simple assignment loop is suspicious.
Maybe stick in stuff in the image loader, image temporary copy code, and keep the blackener to the obvious implementation, then stick stuff in the saver.
I thought some crazy stuff involving function pointers as the function to call to return a black pixel might be promising. Maybe use some out of bounds array math to change one function pointer to point to some other code.
Wouldn't it be nice if the original under the blacked out area could be compressed and then put somewhere else in the image.
It would be much easier if one could just use an algorithm which just displaces the pixels and then forget to randomize the displacement. This could look much more innocent than the above.
That black area has so little expected channel capacity that hiding anything in it is kinda difficult.
Unfortunately the code for the blacking out can be made so small that it is tough to hide anything in it, unless ppm offers some ways to add complexity in some innocent way.
I wonder what means of deciphering the hidden area are allowed, i.e. can I write another program to get the kitty face information back?
That is a really cute picture. I wonder what it is thinking.
Je me souviens.
because the way it dumpes the key into the output is hidden in such a underhanded, innocent way...
HI O WISE PRINCE. WHT TOOK U SO DAM LONG?
Reminds me of a "compression program" back in the early 90's. Seemed to compress better than Zip or RAR and was pretty fast too. You could also test it by compressing and uncompressing a few files, and you got your original back.
Turns out it just copied the contents to a temporary file and "uncompressing" got them back from there, while the "archive" was just random junk. Better yet, the temporary file was just a circular buffer, so when it filled, old data got discarded.
A polar bear is a cartesian bear after a coordinate transform.
Now we can speculate what the authors intentions behind the contest are.
I think their FAQ addresses most points pretty well:
http://underhanded.xcott.com/?page_id=7
I hope sensitizes open source programmers programmers to take great care with peoples submissions to their projects. Only good can come from that.
Je me souviens.
I recently investigated a problem in MS Outlook where an option was set to never show the body of the email when viewing the email, it could only be viewed when forwarding. There were actually a bunch of tick box options to enable and disable this behavior. Reminds me of the Far Side comic with a passenger in an airplane reaching down to adjust his seat and accidentally about to toggle the 'wings stay on / wings fall off' switch.
Arrays, pointers and functions, no memory protection, dangerous strings. I would like to see the same contest with other 'safer' languages, say Java or Python.
What languages are best suited to underhanded tactics, that is, seemingly innocent but evil?. Notice that underhandedness is very different from plain old abuse -- anybody can write unreadable programs in their favorite language. But, can you make them "clearly read" something different from what is actually written?
Seems like an important question for people who use Open Source because of the difficulty for adding back doors. For many applications, security is at least as important as speed, and you already have The Shootout for that.
I don't know whether it is because the code has gotten so massive,or it is because so many coders from the old days have quit,but you really get the feeling that the reason Windows gets hit with crap like the ancient WMF file hack is not because they WANT to keep those ancient pieces of junk in there,but because nobody knows exactly what it does and removing it causes Windows to fail like Win 3.1 with a buggy TSR. But that is my 02c,YMMV
ACs don't waste your time replying, your posts are never seen by me.
There seems to be an error in the supplied ppm.c library file:
p.rgb[i] = z.pixel[y][(x+i)*3*z.bpp];
This only ever gets the R component, as all offsets are multiples of 3. I think the right code is:
p.rgb[i] = z.pixel[y][(x*3+i)*z.bpp];
Maybe this is part of the assignment :-).
Taking a look at the 2006 entry reminds me of a program I used to have to work on:
Essentially it was a giant checkbook for a city government organization for some sort of subsidized housing program. There were two numbers to be calculated along with a grand total (primary and interest maybe. I forget now) The code took about 10 minutes to execute and looked something like this... and yes this was unfortunately in Visual Basic
Label1.Caption = Function1
Label2.Caption = Function2
GrandTotal.Caption = Function1 + Function2
Some of the functions themselves were already bloated to begin with. That ontop of calling both of them twice was just kinda nasty though.
Pancakes. Oh I blew it.
This cheers me up just a little.
We rage against the management decisions of MS, but I'm positive the ranks are filled with decent guys just trying to pay for dinner & rent.
"We haven't a clue what this does but it's vital..."
Seems to me that if the source were opened, within 5 years we'd at least know what all the hacks did, even if they were still necessary.
My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
What that article sums up better than I can,but I'll try to anyway for the "never RTFL" crowd,is that they do clean code. But if you'll look at the comments nearly all the ugliness comes from backwards compatibility. If I had to guess I'd say there is just too much legacy crap that should have been VM'd left floating in the system folder. I do remember reading an article where Allchin himself spent two weeks cooking up a VERY ugly hack involving memory pointers just so that Sim City would run in Win95,because apparently it exploited a bug in the DOS memory subsystem.
And while IMHO I agreed with the backwards compatibility above all mantra when they were converting the DOS users to Win9x to me it seemed the height of insanity to keep all the kludge in once we passed the 1.0Ghz mark when a VM could have run it without leaving a bunch of garbage behind. I mean honestly who cares if a program written for a 30Mhz 486 can't run at the full speed of your 2.0Ghz CPU? Personally I'd like a VM that I could control the speed of,then I wouldn't need DOSbox and MOSLO for ancient programs. I could go one about how Vista is proof that backwards compatibility plus new technologies ultimately don't mix,but hopefully anyone who wishes to know more will check out the link to the excellent article you found. Thanks again for that BTW. And as always this is my 02c,YMMV
ACs don't waste your time replying, your posts are never seen by me.