All challenges

Gift card race condition

webhard300pts

Gift card race condition

A wallet app redeems a one-time gift card with a non-atomic check-then-update: it reads the card as unused, then later marks it used. Firing many redemptions at once lets them all pass the check before any marks it used, crediting the balance repeatedly, enough to buy a voucher whose contents hold the flag.

How to reach it

Run the challenge locally with its docker-compose. The flagger sidecar writes your per-run flag into the voucher before the app starts. The service speaks HTTP on port 8080; the redeem endpoint is the entry point.

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: giftcard-race
      FLAG_PATH: /flag/flag.txt
    volumes:
      - flag:/flag
  challenge:
    image: matejbasic/giftcard-race: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 giftcard-race

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