News for hackers. Stuff that matters.
Re:Zip Bomb by jefffoster on Friday October 05, 2012 @06:59AM (#4616364)
I found a similar file to this (a zip file that contains itself) and e-mailed it to a friend at work. He never received it, but I thought nothing of it (I assumed the email filters just destroyed it).

A days later the mail server stops working and the sysadmin turns up at my desk. Turns out the anti-virus scanner had been unzipping and scanning repeatedly. It eventually filled up the entire disk and bad things happened.

Re:Zip Bomb by chrismorgan on Friday October 05, 2012 @10:45AM (#4617087)
That reminds me of an incident when I was in year 8: seeing how deeply nested I could get directories on Windows. H:\a\a\a\a\..., eventually it stopped working. (I played the game with my friend... he went for creating a new directory at each level, after a little I became sensible and went for copying and pasting, thus multiplying the depth by two each level which of course achieves the goal pretty quickly - so I won by a considerable margin.)

The school IT manager (who, incidentally, apart from this once I was always on good terms with) was rather annoyed at me the next day, for the nightly backup had fallen over the previous night and he had found the problem. You see, what to me was H:\ was \\galaxy\users$\chrism, which on that server was D:\users\chrism. So that 256-or-so character path became longer than 256 characters on the server and the backup software hadn't been written carefully enough to cope with what was a perfectly valid NTFS path, but not a valid path for the normal Win32 API function calls.

How was I to know it would do that?

Re:Zip Bomb by essayist on Friday October 05, 2012 @11:51AM (#4617346)
Years ago, I was an applications programmer in San Francisco working on a timesharing language called EPS. The mainframes were all in Massachusetts. (Think dial-up terminals, mainframes, and 450 BAUD being considered fast.)

EPS, an interpreted language, was designed to let financial analysts run economic projections. It contained various kinds of arrays.

One day, the systems programmers announced a new feature, first released to the test mainframe: a new structure, called containers IIRC, with the twist being that any cell in a container could itself consist of a container.

You know where this is going:

    For I = 1 to 100
      ContX[1] = ContX
    EndFOR
10 seconds later, EPS on the test mainframe had crashed. Coincidence? Hmmmmmm.

So far, my cover was my inquiring mind. But then I ran the loop again, with the same results.

A minute later, there was Massachusetts on the phone, in the person of my friend Kevin, lead EPS developer: "Hey, the answer is 47. What the hell are you doing?"

Re:Zip Bomb by ChuckMcM on Friday October 05, 2012 @04:32PM (#4618564)
Difference between hackers and coders -

Rule: "You can have at most 50 sub-directories."

coder-action:

     #define MAX_SUB_DIRECTORY_NUM 50
hacker-action:

    main(int argc, char *argv[]) {
      int i;
      for (i = 0; i < atoi(argv[1]); i++) {
          create_subdir( ... ); 
      }
    }
Plus experiments.

The difference is that the coder is just doing their job so they note the limitation and move on, the hacker is curious and trys to test to see if its a hard limit, a soft limit, a big problem, a little problem.

Re:Zip Bomb by mirkules on Friday October 05, 2012 @07:34PM (#4619163)
A good developer should be testing for that stuff too. But hackers test these things out of curiosity, developers do it out of attention to detail. A great developer will do both :)
Re:Zip Bomb by jamoes on Friday October 05, 2012 @03:23PM (#4618270)
My brother did this exact same thing (competing with his friend to try to make as many folders as possible), only he got a 1 week suspension for "hacking". The IT manager was really pissed and pressed the school administrators to make an example out of them.

I was outraged. Basically, the IT manager preferred to use punishment as his means of security, rather than actually doing his job.

Re:Zip Bomb by johngalt on Saturday October 06, 2012 @11:32AM (#4620759)
Being able to break something =/= IT not doing their job.

Tossing a brick through a window doesn't mean that the window should have been thicker.

Re:Zip Bomb by adimitrov on Saturday October 06, 2012 @04:20PM (#4621578)
Except that this was not 'tossing a brick,' it was maybe knocking on a window to see what sound it makes, and the window then falling apart for no apparent reason.

There is nobody to blame for this, actually. Neither could the kid have known that this was bad (and the child-like curiosity is hardly something worth a punishment,) nor could the sysadmin really do anything to prevent it, except hang up a memo: please don't do that.

Though, in that case, you'd have some kids doing that over and over again out of a very different kind of curiosity.

Re:Zip Bomb by gizmo686 on Sunday October 07, 2012 @02:18AM (#4622776)
I agree that we should not punish kids for expermentation (I am outraged when schools do anything other than encourage it). However, if playing around with a computer causes notable damage, I do have to wonder what would happen with viruses or someone who is actually malicius.
Re:Zip Bomb by derefr on Friday October 05, 2012 @10:12PM (#4619513)
The NTFS 256-character-path bit me before when I moved a deeply-nested folder from somewhere with a short path (like the root of a disk) to somewhere with a slightly longer one (like my desktop) and then went to delete it. Windows doesn't even complain in this case--it just completely ignores all attempt to delete the folder (even if you, say, put it in the trash and then empty the trash) because it can't complete the process of gathering up the list of paths to delete.

It's very confusing when you're not expecting it--you can dig into the folder and delete all the subdirectories of it that don't have overlong paths just fine, but there'll be one series of empty directories left over that just refuse to go away. Then you flatten them out from their nested configuration, and suddenly the problem goes away.

Re:Zip Bomb by tobias3 on Saturday October 06, 2012 @09:51AM (#4620513)
Had this problem once as well. It's so weird that explorer doesn't use the API without the path length restriction...
Re:Zip Bomb by TazeTSchnitzel on Friday October 05, 2012 @11:24AM (#4617252)
One of many examples of why Windows's arbitrary path length restriction is ridiculous.
Re:Zip Bomb by duskwuff on Friday October 05, 2012 @12:24PM (#4617509)
Most UNIX systems have a PATH_MAX. It's not just Windows.
Re:Zip Bomb by krakensden on Friday October 05, 2012 @08:23PM (#4619296)
PATH_MAX is defined but meaningless on both Linux and OS X.
Re:Zip Bomb by comex on Friday October 05, 2012 @09:43PM (#4619476)
Unfortunately, this is not true. The OS X kernel can't deal with paths longer than MAXPATHLEN, which is defined as 1024.
Re:Zip Bomb by TazeTSchnitzel on Friday October 05, 2012 @03:27PM (#4618288)
Perhaps, but Windows's is a bit too low.
Re:Zip Bomb by hoov on Friday October 05, 2012 @04:45PM (#4618607)
While MAX_PATH is 260, most of the Unicode variants of the API functions allow for paths of 32,767 characters [1]. That seems like a decent length.

[1] http://msdn.microsoft.com/en-us/library/windows/desktop/aa36...

Re:Zip Bomb by gburt on Friday October 05, 2012 @06:38PM (#4618989)
So there's a constant for path length that only applies sometimes...
Re:Zip Bomb by flatline on Friday October 05, 2012 @11:08PM (#4619626)
This is also the case on Unix. According to Advanced Programming in the Unix Environment, it is true of many of these so-called limits. The POSIX standard defined many values that were too small for modern-day use, such as _POSIX_PATH_MAX set to 255. The non-posix values are not all defined in limits.h, and must be queried at runtime. Even then, some are indeterminate. But at least you're not relegated to 255 characters;)
Re:Zip Bomb by TazeTSchnitzel on Friday October 05, 2012 @04:53PM (#4618638)
Oh, that's somewhat reassuring. I'll surely benefit from it in 10 years time. :/
Re:Zip Bomb by hoov on Saturday October 06, 2012 @03:00PM (#4621344)
I'm not sure that I know what you mean. These functions aren't obscure and have been around for quite a while. For example: CreateFileW [1]. It's just good hygiene to use the Unicode variants and normalize to UNC where appropriate. This has been the case for years.

[1] http://msdn.microsoft.com/en-us/library/windows/desktop/aa36...

Re:Zip Bomb by TazeTSchnitzel on Saturday October 06, 2012 @03:02PM (#4621355)
I mean that to maintain compatibility with legacy stuff I expect I won't be able to take advantage of it for quite a while.
Re:Zip Bomb by im3w1l on Friday October 05, 2012 @03:04PM (#4618198)
The write limit should be lower than the read limit.
Re:Zip Bomb by gizmo686 on Sunday October 07, 2012 @02:14AM (#4622770)
I had a worse problem when I helped my parents recover their backups. The backup itself had a fair amount of folder nesting, but was within the 256 character limit. At some point, they moved the backup into another folder that had the date, and computer for the backups. When they tried to access it, Windows gave a cryptic error message about corrupted files.
Re:Zip Bomb by halfasleep on Saturday October 06, 2012 @02:32AM (#4619961)
That reminds me of using the undelete utility that came around the Windows 3.1/DOS 6.2 sort of time. All the files it would offer to recover had file names like "testdoc.do?", and if you didn't set the final character it created a file with a wildcard in the name.
Re:Zip Bomb by malkia on Friday October 05, 2012 @03:58PM (#4618432)
Do that, but then rename each folder to a very long name, and go back one directory up in the tree e.g. d:\h\h\h becomes d:\h\h\very_long_h then d:\h\verl_long_h\very_long_h, etc.

It was "simple" way to hide files, by making their names very long indeed.

Re:Zip Bomb by fromdoon on Friday October 05, 2012 @08:07AM (#4616510)
>> ... eventually filled up the entire disk and bad things happened

I can only imagine what would have happened. Can you share more details about that.

Also, wonder how the mail servers these days are equipped to handle such attachments. Can someone throw light on that? Is it just plain simple to detect these files?

Re:Zip Bomb by tonyz on Friday October 05, 2012 @08:42AM (#4616603)
A well-known example of a zip quine: http://steike.com/code/useless/zip-file-quine/

Compression quines and bombs are a great way to screw up automated systems. Possessing or transmitting them can easily cause a denial of service.

From Wikipedia: A quine is a computer program which takes no input and produces a copy of its own source code as its only output. http://en.wikipedia.org/wiki/Quine_(computing)

Re:Zip Bomb by krenoten on Friday October 05, 2012 @09:38AM (#4616797)
Computational complexity attacks are actually quite rampant in various types of software. A good example is an "evil regex" which is usable on software that accepts regular expressions as input, and similarly costly regexes already contained in software can be exploited by certain crafted input to induce a DOS.

http://en.wikipedia.org/wiki/ReDoS

Re:Zip Bomb by omh on Friday October 05, 2012 @10:04AM (#4616893)
All of the email virus scanners I've used are aware of this sort of thing, and will have a maximum depth or maximum size for scanning within attachments. I don't think any of them try to "detect" them in any cleverer way.
Re:Zip Bomb by lignuist on Friday October 05, 2012 @10:16AM (#4616941)
So I should just place my malicious software deeper than n levels or put it in a huge file?

Or are those scanners just rejecting files that are too large or deep?

Re:Zip Bomb by krenoten on Friday October 05, 2012 @11:35AM (#4617287)
"The Grugq: I’m not joking. You don’t even need to do that. You just send an e-mail which says, you can literally just say, "Run this code." Some of the anti-phishing guys I’ve worked with are just shocked at what happens. I had some friends who worked in corporate security who had to do a cleanup after they got hit with e-mails which said literally, "click on this" and they had 10 or 20 people who did. It was less than 1 percent, but it was enough. People will do it and even on a locked-down corporate PC, it doesn’t matter. If you can get an HTTP connection back out to the Web, you can then tunnel in over that."

(The Grugq sells high value 0days and is a respected member of the hacking community) http://www.csoonline.com/article/216370/where-is-hacking-now...

Re:Zip Bomb by SoftwareMaven on Friday October 05, 2012 @03:31PM (#4618312)
That was how RSA was breached, which led to the eventual loss of the SecureID master key (and follow-on breeches at DoD suppliers).
Re:Zip Bomb by philiac on Saturday October 06, 2012 @05:39AM (#4620187)
What does RSA stand for? I was on their (SecurID) related site, and checked out the "about" page, but the acronym is never defined.
Re:Zip Bomb by sokoloff on Saturday October 06, 2012 @07:13AM (#4620271)
Initials of the three inventors (discoverers?) of the algorithm: http://en.wikipedia.org/wiki/RSA_(algorithm)
Re:Zip Bomb by gruturo on Saturday October 06, 2012 @07:27AM (#4620278)
(Ron) Rivest, (Adi) Shamir, (Leonard) Adleman
Re:Zip Bomb by DanBC on Friday October 05, 2012 @10:27AM (#4616989)
You used to be able to just password protect the file, and instruct users to enter the password.

Some malware is remarkably unsophisticated and relied on users installing it and giving it permissions to run.

I hope they're not silently rejecting files.

Re:Zip Bomb by darkarmani on Friday October 05, 2012 @09:10PM (#4619406)
You can't put it too deep. The scanner should stop attempting to unzip at a certain depth. Presumably, any file that has more than N depth is malicious and should get flagged, but who knows if the person that configured the scanner did id right?

I've worked with a leading commercial scanner that failed to respect the max depth parameter even when set. It would scan for days before we killed it.

Re:Zip Bomb by makmanalp on Friday October 05, 2012 @10:52AM (#4617108)
This is why you set up monitoring. You could notice either a) the long-lasting cpu-eating subprocess or b)just the rapid diminishing of disk space.
Re:Zip Bomb by keeperofdakeys on Saturday October 06, 2012 @05:00AM (#4620155)
When I did a databases class at a University a few years back, we were given a share on a webserver to run php programs on. Naturally they didn't turn off php error logging, and by default php doesn't report errors to the user. One of the students accidentally wrote an infinite-loop, that generated an error on each iteration, filling up the disk. They never did fix the problem, just deleted the log file both times it occurred.
Re:Zip Bomb by gcr on Friday October 05, 2012 @09:10PM (#4619404)
That's hilarious -- the viros scanner, which is designed to protect the mail server, was what wound up destroying it in the first place.
Re:Zip Bomb by khuey on Saturday October 06, 2012 @01:35PM (#4621093)
The virus scanner is designed to protect the mail server's clients.