Skip to content

Claude Opus 5.5 (effort default (no --effort flag) · thinking on) on Fix catastrophic-backtracking (ReDoS) regexes in signup validators without changing what they accept

AClaude Opus 5.5default · thinking on · Claude Code 2.1.299 (headless -p) · cloud · 2026-10-17 · by @bobsiopener

Trust 80%Fully autonomoussuccess · first try
Estimated cost
$0.27
Wall time
2m
Human step-ins
0
Outcome
Pass

Compare with other models on this task →

Summary

Exact prompt

# Task: fix a ReDoS in the signup validators A pen-test found that crafted inputs make `validate.py` hang the API worker (catastrophic regex backtracking). Make all three validators run in linear-ish time on any input up to 100 KB, **without changing which inputs they accept**: for every input the original accepts or rejects in reasonable time, your version must return the same answer. Notes: `is_username` should accept exactly what the original accepts (word characters with single optional whitespace separators, max 64 chars) - including the empty string. Keep function names/signatures. Python stdlib only (`re` is fine; so is not using regex at all). Write `SECURITY_FIX.md` (2+ lines). No network.

Easy to make fast, hard to keep the exact accepted language: trailing-separator locals, the `$`-before-final-newline quirk, unicode \w, the 64-char cap and empty-string acceptance are all compared against the original. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).

Success criteria: 1. same_accept_reject: is_email/is_username/is_tag_list return the same result as the original on 10,619 validator calls (fixed edge cases + seeded random strings; strings over 20 chars only for is_username because the original is exponential there). 2. linear_time: on 10 crafted inputs up to 100 KB (x3 validators) the slowest call takes < 0.25 s (subprocess capped at 20 s). 3. notes_present: SECURITY_FIX.md has at least 2 lines.

Setup notes: Use Case Scout batch 5 case e09-redos-validator (offline fixture). Prepared with batch5/prepare.sh; hidden key/tests kept outside the agent's work dir. Prompt = TASK.md verbatim. Scored with the scout's scorer: `python score.py WORKDIR KEYDIR`. Tools: Read/Write/Edit/Glob/Grep/Bash, web disabled. Single run, no retries. 1-min load average at scoring: 0.44. Claude Code's own reported cost for claude-opus-5.5: $0.268592. Score: 3/3 checks. Cost is an ESTIMATE: measured tokens x pricing.json list price (Claude Pro subscription, nothing billed); input_tokens include cache reads and writes. Single run.

Estimated cost List-price estimate; not actually billed.

Metrics

Estimated cost
$0.27
Wall time
2m
Human step-ins
0
Turns
6
Model usage
ModelInput tokOutput tokCost
AClaude Opus 5.5anthropic/claude-opus-5.5effort default (no --effort flag) · thinking on129,4667,042$0.27

Reproduce this run

  1. Use the use case prompt on the use case page.
  2. Same setup: Claude Opus 5.5 (anthropic/claude-opus-5.5, effort default (no --effort flag) · thinking on) via Claude Code 2.1.299 (headless -p), cloud.
  3. It counts as a success only if it meets every success criterion: 1. same_accept_reject: is_email/is_username/is_tag_list return the same result as the original on 10,619 validator calls (fixed edge cases + seeded random strings; strings over 20 chars only for is_username because the original is exponential there). 2. linear_time: on 10 crafted inputs up to 100 KB (x3 validators) the slowest call takes < 0.25 s (subprocess capped at 20 s). 3. notes_present: SECURITY_FIX.md has at least 2 lines.
  4. Log model, tokens, wall time, human step-ins and the evidence log, then submit it as a reproduction. A different model? Submit a head-to-head rerun.

How runs are scored: Methodology.

Was this useful?

⇄ Rerun on another model

Automated checks

Trust 80% comes from these checks (how Trust % works).

Evidence log
[
 {
  "duration_api_ms": 74278,
  "stop_reason": "end_turn",
  "session_id": "[REDACTED]",
  "total_cost_usd": 0.26859220000000006,
  "usage": {
   "input_tokens": 12,
   "cache_creation_input_tokens": 13053,
   "cache_read_input_tokens": 116401,
   "output_tokens": 7042,
   "output_tokens_details": {
    "thinking_tokens": 3259
   },
   "server_tool_use": {
    "web_search_requests": 0,
    "web_fetch_requests": 0
   },
   "service_tier": "standard",
   "cache_creation": {
    "ephemeral_1h_input_tokens": 13053,
    "ephemeral_5m_input_tokens": 0
   },
   "inference_geo": "global",
   "iterations": [
    {
     "input_tokens": 2,
     "output_tokens": 843,
     "cache_read_input_tokens": 24195,
     "cache_creation_input_tokens": 1004,
     "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 1004
     },
     "type": "message"
    }
   ],
   "speed": "standard",
   "fallback_credit": null
  },
  "modelUsage": {
   "claude-opus-5-5": {
    "inputTokens": 12,
    "outputTokens": 7042,
    "cacheReadInputTokens": 116401,
    "cacheCreationInputTokens": 13053,
    "webSearchRequests": 0,
    "costUSD": 0.26859220000000006,
    "contextWindow": 1000000,
    "maxOutputTokens": 128000,
    "thinkingTokens": 3259,
    "canonicalModel": "claude-opus-5-5",
    "provider": "firstParty",
    "costBasis": "list"
   }
  },
  "permission_denials": [],
  "terminal_reason": "completed",
  "fast_mode_state": "off",
  "fast_mode_disabled_reason": "sdk_opt_in_required",
  "subagent_stats": {
   "spawned": 0,
   "requested": {
    "background": 0,
    "foreground": 0,
    "unset": 0
   },
   "started_in_background": 0,
   "max_depth": 0,
   "spawned_by_subagents": 0,
   "completed": 0,
   "failed": 0,
   "killed": {
    "parent": 0,
    "user": 0,
    "system": 0
   },
   "refused": {
    "depth_limit": 0,
    "concurrency_limit": 0,
    "budget": 0
   },
   "by_type": {}
  },
  "safety_stops": 0,
  "is_error": false,
  "num_turns": 6,
  "subtype": "success",
  "api_error_status": null,
  "result": "All three validators in `validate.py` are fixed. They now accept exactly the same inputs as before and finish in milliseconds on hostile 100 KB inputs. A comparison against the original found no differences.\n\n**Cause:** each pattern had a repeated group whose separator was optional, like `(\\w+\\s?)*`. A run such as `aaaa\u2026` can be split across repetitions in exponentially many ways, so a nearly-valid input like `\"a\"*30 + \"!\"` makes the regex engine try them all. The 64-character limit on usernames didn't help, because 64 characters is already enough to hang.\n\n**Fix:** I rewrote each pattern so that any string can match in only one way. Function names and signatures are unchanged:\n\n| Validator | New pattern |\n|---|---|\n| `is_email` | `^[a-zA-Z0-9]+(?:[._+-][a-zA-Z0-9]+)*[._+-]?@(?:[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*\\.)+[a-zA-Z]{2,}$` |\n| `is_username` | `^(?:\\w+(?:\\s\\w+)*\\s?)?$`, still with the 64-character limit and still accepting the empty string |\n| `is_tag_list` | `^#?[a-z0-9]+(?:(?:,#?|#)[a-z0-9]+)*,?$` |\n\nI kept `^\u2026$` with `.match()` so some non-obvious accepts still behave as before:\n- `\"a b \\n\"` and `\"\\n\"` are valid usernames, because `$` also matches just before a final newline.\n- `\"ab#cd\"` is a valid tag list.\n- `\\w` and `\\s` still match Unicode letters and whitespace, not just ASCII.\n\n**Testing:**\n- **Same answers:** I compared old and new on about 25 million inputs: every string up to 7\u20138 characters built from characters chosen to hit the edge cases, 600,000 random strings, and some hand-picked cases. Every answer matched.\n- **Speed:** adversarial 100 KB inputs (long letter runs, `a.a.a\u2026!`, `#a#a\u2026!`, `a,#a,#\u2026#`, and so on) each took at most about 19 ms. The username pattern on its own, without the length check, takes about 5 ms on 100 KB.\n\nI also wrote `SECURITY_FIX.md`, which explains the cause, the fix and how it was checked. The test script is at `/tmp/rt/check.py` and is not in the repo.",
  "ttft_ms": 1842,
  "type": "result",
  "duration_ms": 93842,
  "uuid": "[REDACTED]",
  "ttft_stream_ms": 1267,
  "time_to_request_ms": 247,
  "first_content_frame_ms": 1268,
  "queued_turn_count": 0,
  "result_index": 0
 }
]

Get new runs and ranking changes weekly