All challenges

SHA-3 buffer overflow

cryptomedium300pts

SHA-3 buffer overflow

CVE-2022-37454 is a buffer overflow in the _sha3 C module shipped with CPython 3.10 and earlier. Feeding a hash object a very large amount of data (around 4 GB in a single update) overflows an internal length field and corrupts memory. The immediate effect is a SIGSEGV crash of the interpreter, and under the right conditions the corruption can be pushed further.

The proof of concept creates a sha3_224 object and calls update twice, once with a single byte and once with roughly 4 GB, so the combined length wraps. Your job is to drive the vulnerable service into that state.

import hashlib
h = hashlib.sha3_224()
h.update(b"\x00" * 1)
h.update(b"\x00" * 4294967295)

How to reach it

Run the challenge locally with its docker-compose. The flagger sidecar writes your per-run flag into the container before it starts. The service speaks HTTP on port 8080.

Run this challenge

Spin it up locally with Docker. The flagger sidecar fetches a per-run flag into a shared volume, then the challenge container boots and reads it.

compose.yml
services:
  flagger:
    image: matejbasic/rootcause-flagger:1.0
    environment:
      ROOTCAUSE_API_URL: https://root-cause-api.matejbasic.com
      ROOTCAUSE_API_KEY: ${ROOTCAUSE_API_KEY}
      ROOTCAUSE_CHALLENGE: sha3-overflow
      FLAG_PATH: /flag/flag.txt
    volumes:
      - flag:/flag
  challenge:
    image: matejbasic/cve-2022-37454:1.0
    depends_on:
      flagger:
        condition: service_completed_successfully
    environment:
      FLAG_PATH: /flag/flag.txt
    volumes:
      - flag:/flag
    ports:
      - "8080:8080"
volumes:
  flag:
one-line CLI
rootcause start sha3-overflow

The rootcause CLI does all of this in one command. Running a challenge needs your API key, which you generate in your profile.