5 ms·
The underhanded C contest shows it is so easy to insert backdoors into C code that even someone staring at the code for a while wouldn't find. So why did this
by londons_explore 6y ago
The underhanded C contest shows it is so easy to insert backdoors into C code that even someone staring at the code for a while wouldn't find.
So why did this attacker choose such an obvious 'typo' rather than a subtle flaw in a large patch set?
- IshKebab 6y agoBecause of selection bias - if they had chosen something less subtle then we wouldn't be talking about it.
- brobdingnagians 6y agoMaybe it is a smoke screen, put in something likely to be found and something that won't. Everyone pats themselves on the back for finding the obvious one...
- gvjddbnvdrbv 6y agoThis seems highly likely.
- nkrisc 6y agoWhy not just include the thing that won't be found and call it a day? Including a red herring to invite extra scrutiny doesn't seem wise if you're trying to hide something.
- flingo 6y agoStep 1: Get 3 pigs. Step 2: Number them 1, 2, and 4. ...
- kubanczyk 6y agoYou've probably meant: if they had chosen something much subtler we wouldn't be talking about it.
- GuB-42 6y agoIt is not so easy, it is a contest, and they show you the winners. And if you look at the "Scoring and Extra Points" section of http://underhanded-c.org/_page_id_5.html http://underhanded-c.org/_page_id_5.html you will notice that it checks most of the boxes. It is short, errors based on human perception (here = vs ==) are good enough, it is innocent looking under syntax highlighting, is is not platform dependent, and it even passes the "irony" check. It is just the plausible deniability that is not great, but it is still defensible with a lot of bad faith.
- mercer 6y agonow I'm wondering if syntax highlighting shouldn't somehow make an assignment inside an if statement (and the variants) a bright red, or something like that.
- jhardy54 6y agoYou may be interested in linters.
- SAI_Peregrinus 6y agoOr IDEs, many of which will continually lint code.
- mhh__ 6y agoIt should really be forbidden by the compiler these days, or at least a very loud warning.
- GuB-42 6y agoIt would break these kinds of constructs, which are common. if ((fd = open(...)) != -1) { /* do something with fd */ } else { perror("open"); } The compiler outputs a warning when you have something like "if (a = b)". If that's what you mean (it sometimes is), you have to write it "if ((a = b))" to silence the warning.
- staycoolboy 6y agoGCC warns of assignment in conditional, even without -Wall or -pendantic. I don't know when it started doing that, but it seems like a sore thumb today, different in 2003 maybe?
- not2b 6y agoIt only warns if the assignment doesn't have an extra pair of parentheses. These were added in this case, to silence the warning (so the attack would not be noticed). The parentheses are also needed in this case to get the precedence right, but they won't be needed if '==' were written, so anyone coding this by accident would immediately be warned of the mistake.
- staycoolboy 6y agoOh wow, I didn't know that. Sneaky.