alg: none

Medium

· Backend

Incident

SEV-1

BUG-ALG-NONE

Priority: Critical (auth bypass) · reported by security

Time to fix: 20 min

Failing checks on the shipped build

  • alg none is never trusted

    the classic bypass: expected a truthy value but got false

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

JWT libraries · 2015

Inspired by the 2015 JWT library vulnerabilities: tokens declaring "alg": "none" were accepted without any signature at all — attackers could mint themselves any identity by just… asking nicely.

verify.py decides whether a decoded token is trustworthy.

Code map

# Decides whether a decoded JWT can be trusted.

ALLOWED_ALG = "HS256"

def is_trusted(header, signature_ok):
    alg = header.get("alg")
    if alg == "none":
        return True
    return signature_ok

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

alg: none — Python Bug Hunt

Inspired by the 2015 JWT library vulnerabilities: tokens declaring "alg": "none" were accepted without any signature at all — attackers could mint…

  • Language: Python
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Security, JWT
  • Modelled on: JWT libraries · 2015
  • Visible tests: a properly signed HS256 token is trusted; alg none is never trusted; a bad signature is never trusted
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical (auth bypass))
  • Ticket: BUG-ALG-NONE
  • Reported by: security
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • alg none is never trusted — the classic bypass: expected a truthy value but got false

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Briefing

Inspired by the 2015 JWT library vulnerabilities: tokens declaring "alg": "none" were accepted without any signature at all — attackers could mint themselves any identity by just… asking nicely.

verify.py decides whether a decoded token is trustworthy.

Bug report

BUG-ALG-NONE · Priority: Critical (auth bypass) · Reported by: security

is_trusted(header, signature_ok):

  • ONLY tokens with alg == "HS256" AND a valid signature are trusted
  • "none", "NONE", missing alg — never trusted, signature or not

Observed: a curl with {"alg":"none"} and no signature returns admin data.

Logs

[auth] token alg=none sig=<absent> -> TRUSTED (?!)

The code as shipped

src/auth/verify.py (editable)

# Decides whether a decoded JWT can be trusted.

ALLOWED_ALG = "HS256"

def is_trusted(header, signature_ok):
    alg = header.get("alg")
    if alg == "none":
        return True
    return signature_ok

Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More Python bug hunts.