News Software dev fortifies his blog with 'zip bombs' — attacking bots meet their end with explosive data package

  1. Header pre-scan (compression-ratio + file-count + uncompressed-size)
  2. Byte-cap during extract
  3. Process + timeout or resource limits
It's like both the author and the article writer have never actually solved a problem before.

Even the most basic timeout would stop something like this.

Python:
from multiprocessing import Process
import zipfile, shutil

def do_extract(src, dest):
    with zipfile.ZipFile(src) as zf:
        zf.extractall(dest)

def extract_with_timeout(src, dest, timeout=10):
    p = Process(target=do_extract, args=(src, dest))
    p.start()
    p.join(timeout)
    if p.is_alive():
        p.terminate()
        p.join()
        raise RuntimeError("Extraction timed out")
 
  • Like
Reactions: NinoPino and Grobe
I remember doing that to myself at work back in the day by accident. I was testing what happens when you try to load something large into memory, so I created a three-dimensional array, 1000x1000x1000 bytes in size, not realizing that the array was bigger than the amount of RAM I had. My computer froze while instantiating the array. So yeah, I bombed myself.
 
  1. Header pre-scan (compression-ratio + file-count + uncompressed-size)
  2. Byte-cap during extract
  3. Process + timeout or resource limits
It's like both the author and the article writer have never actually solved a problem before.

Even the most basic timeout would stop something like this.

Python:
from multiprocessing import Process
import zipfile, shutil

def do_extract(src, dest):
    with zipfile.ZipFile(src) as zf:
        zf.extractall(dest)

def extract_with_timeout(src, dest, timeout=10):
    p = Process(target=do_extract, args=(src, dest))
    p.start()
    p.join(timeout)
    if p.is_alive():
        p.terminate()
        p.join()
        raise RuntimeError("Extraction timed out")
If you're familiar with programming, sure. Don't forget you can be interested in one aspect of a field - like computers - without having much knowledge in other aspects. Or you could be like me who... I guess if you've ever played Dungeons and Dragons, it's like a Bard, with a bunch of random knowledge in a bunch of random places. Also, the point of what they did is to shut down the crawlers. They probably have stuff to handle regular errors and just move on.
 

TRENDING THREADS