Repository navigation
Description
Parent epic: #132
Priority: P1
Objetivo
Add a level-based challenge to the playground: visitors try to get a secret out of a demo database through a guard. The baseline levels (keyword list, first-word check) can be beaten and show why those defenses fail; the sqlguardllm levels are the real challenge. A bypass of a sqlguardllm level is reported privately and credited in a hall of fame after the fix. It gives people a reason to share the project.
Scope
- New page
playground/challenge/(or a "Challenge" mode in the existing page) with the same stack: static HTML, CSS and JS, Pyodide,sqlite3in the browser. No backend, no analytics, no cookies, no storage; progress may live in the URL fragment. - Levels in
playground/challenge/levels.json, each with a validator, a fresh in-memory SQLite database, a goal and a short story, in English and Spanish:- L1, keyword list (same rule as the keyword baseline in
benchmarks/guards/run.py). Goal: change data. - L2, first-word check (same rule as the first-word baseline). Goal: delete rows.
- L3, sqlguardllm with a hidden column. Goal: read the hidden value.
- L4, sqlguardllm with a hidden column, a masked column and a row filter. Goal: read another branch's row.
- L1, keyword list (same rule as the keyword baseline in
- Deterministic win check: the level's validator accepts the query, the query runs on a fresh database, and the goal check passes (secret in the result, or rows changed). The database is reset on every attempt.
- After an L1 or L2 win: explain why the trick works and link docs/BENCHMARK.md and the attack gallery. The share link carries only the level and the result.
- After an L3 or L4 win: never put the SQL in a URL. Show how to report it privately (GitHub private vulnerability reporting, per SECURITY.md) and link the hall of fame.
docs/HALL_OF_FAME.md: reporters are credited only after the fix is released. Starts empty. SECURITY.md links it.- README.md and README.es.md link the challenge from the Playground section.
Security impact
Everything runs in the visitor's browser, so the secrets are not secret to someone who reads the page source. The prize is a verified guard bypass, not the flag, and the page says so. Do not add real sqlguardllm bypasses, third-party findings or solutions for L3/L4 anywhere in the repository.
Criterios de aceptación
- The challenge loads in the Playwright suite (
playground/test): every level renders in English and Spanish, with no horizontal scroll at 360 px. - Playwright tests: one known solution solves L1 and one solves L2 (kept only in the tests, never shown in the UI); attacks from
tests/corpusfail on L3 and L4; the database resets between attempts. - With a stubbed validator, an L3/L4 win shows the private-report instructions and puts no SQL in the URL (test).
- Parity test: the challenge's baseline validators give the same accept/reject as the benchmark baselines on the benchmark corpora.
-
docs/HALL_OF_FAME.mdexists and is linked from SECURITY.md; README.md and README.es.md link the challenge. - The playground workflow, ruff, mypy and pytest are green; after the Pages deploy the challenge URL returns HTTP 200.
Archivos relevantes
playground/index.html,playground/app.js,playground/engine.py,playground/style.cssplayground/challenge/(new),playground/test/benchmarks/guards/run.py(baseline rules, for the parity test)docs/HALL_OF_FAME.md(new),SECURITY.md,README.md,README.es.md,mkdocs.yml
Out of scope: package versions, .github/workflows/release.yml, PRs #155 and #156.
Claude API proposal (AGENTS.md)
Workflow run: https://github.com/jmmana/sqlguardllm/actions/runs/46439805866 · model claude-sonnet-5-5 · manifest in the run artifact. Review it against the code; model output is not validation evidence.
proposal.md
Proposal: DIST-018, a "break the firewall" challenge in the playground
Suggestions for the maintainer. Nothing here is implemented. Assumptions are labelled [A]; things I could not verify from the excerpts are in Open questions.
1. Goal
Ship a four-level challenge page in the playground:
- L1 and L2 use the two home-made baselines and are beatable. They teach why keyword lists and first-word checks fail.
- L3 and L4 use the real sqlguardllm validator. A bypass is reported privately and credited in
docs/HALL_OF_FAME.mdonly after the fix is released.
Constraints from the issue stay fixed: static HTML/CSS/JS, Pyodide and sqlite3 in the browser, with no backend, analytics, cookies or storage. Progress may live in the URL fragment.
2. Files to change
New files:
playground/challenge/index.html,challenge.js,challenge.cssplayground/challenge/levels.jsonplayground/challenge/baselines.py(the L1/L2 validators)playground/test/challenge.spec.*and a fixtures file for the known L1/L2 solutions (tests only)docs/HALL_OF_FAME.md(empty table plus the credit rule)tests/test_challenge_parity.py
Edited files:
SECURITY.md(link the hall of fame)README.md,README.es.md(link from the Playground section)mkdocs.yml(nav entry for the hall of fame)playground/engine.pyonly if the existing engine can't be reused as-is [A: it exposes acheck()-style entry thatchallenge.jscan call]
benchmarks/guards/run.py should stay untouched. See the parity item below.
3. Proposed implementation
Separate page, shared engine
I'd use a separate page, playground/challenge/, rather than a mode in index.html. That keeps the existing playground's tests and layout unaffected. challenge.js reuses the Pyodide bootstrap and engine loading from app.js. If that code isn't importable, extract only the bootstrap into a small shared module, as a separate prep commit, so the diff stays reviewable.
levels.json schema (one entry per level)
{
"id": "L1",
"validator": "keyword",
"title": {"en": "...", "es": "..."},
"story": {"en": "...", "es": "..."},
"goal": {"en": "...", "es": "..."},
"schema_sql": "CREATE TABLE ...; INSERT ...;",
"goal_check": {"type": "rows_changed", "table": "accounts"},
"policy": null
}goal_check.typeis one ofsecret_in_result(withsecret) orrows_changed(withtable).- L3 and L4 carry a
policyobject: hidden column for L3; hidden column, masked column and row filter for L4. I'd mirror the playground's existing policy format. [A: the playground already accepts a policy in a JSON shape I can reuse.] - The
enandesstrings live in the JSON so tests can iterate every level in both languages.
Win check (deterministic, per attempt)
- Open a fresh in-memory SQLite DB from
schema_sql(reset on every attempt, never reused). - Run the level's validator on the query. If it rejects, show the reason and stop.
- Execute the query, then evaluate
goal_check:secret_in_result: the secret string appears in any result cell.rows_changed: row count or content differs from the pristine snapshot.
- All three must hold to win.
Run the query with a statement-level guard against runaway queries, for example a progress-handler row or step cap. Everything is client-side, so this protects the visitor's tab, not a server.
Baselines, with a parity guarantee
The issue requires L1/L2 to match the baselines in benchmarks/guards/run.py. Duplicating the rules in baselines.py invites drift, so I'd make the parity test the guard rail:
- The challenge ships its own
baselines.pyfor Pyodide. tests/test_challenge_parity.pyloads both implementations and asserts identical accept/reject on every case in the attack and legitimate corpora (bench.attacks(),bench.legitimate()as intests/test_guard_benchmark.py).- Alternative, if the maintainer prefers a single source of truth: move the two baseline functions into an importable module that both
run.pyand the challenge load. That touchesrun.py, so I've listed it under Open questions rather than assuming it.
Post-win behaviour
- L1/L2 win: explain why the trick works, and link
docs/BENCHMARK.mdanddocs/ATTACK_GALLERY.md. The share link (URL fragment) carries onlylevelandresult(e.g.#L1=won), never the SQL. - L3/L4 win: show private-reporting instructions (GitHub private vulnerability reporting, per
SECURITY.md) and a link to the hall of fame. No SQL goes into the URL, DOM attributes, or any share link. Clearly state that the page is client-side, so the flag is readable from the source and the prize is a verified guard bypass, not the flag.
I'd also suggest the report instructions tell people to reproduce the bypass against the published package and include the version, so the maintainer doesn't have to trust the in-browser result.
Hall of fame
docs/HALL_OF_FAME.md starts with an empty table (reporter, date, release containing the fix) and a short rule: credit only after the fix ships. Link it from SECURITY.md and mkdocs.yml.
Hard rule: no bypasses in the repo
Per the issue, no real sqlguardllm bypass, third-party finding, or L3/L4 solution anywhere in the repository, including tests, fixtures, comments, commit messages and branch names. L1/L2 known solutions live only in the Playwright tests, never in the UI, and must be written so they are demonstrably baseline-only. They must not double as guidance for L3/L4.
4. Tests
Playwright (playground/test):
- Every level renders in
enandes, with no horizontal scroll at a 360 px viewport. - One known solution solves L1 and one solves L2 (kept in the test file only).
- Representative attacks from
tests/corpusare rejected on L3 and L4. Load them from the corpus at test time rather than copying them into the test file. - The database resets between attempts: run a mutating L1 solution, then confirm the next attempt sees pristine data.
- With a stubbed validator forced to accept, an L3/L4 win shows the private-report instructions, and
location.href/location.hashcontain no SQL (assert on the fragment and on any generated share link).
Python (pytest):
tests/test_challenge_parity.py: baseline accept/reject parity against the benchmark corpora.- A small test that
levels.jsonhas both languages for every string field and that every level'svalidatoris a known key.
Docs and CI checks:
HALL_OF_FAME.mdexists andSECURITY.mdlinks it; both READMEs link the challenge (simple string or link-presence assertion).- The playground workflow, ruff, mypy and pytest are green. The post-deploy HTTP 200 check on the challenge URL is a manual or workflow step after Pages publishes.
5. Scope control
To keep the PR reviewable, I'd split it:
- PR A: page, levels, baselines, win check, L1/L2 flow, parity test.
- PR B: L3/L4 wiring with the stubbed-validator test, hall of fame, SECURITY/README/mkdocs links.
Out of scope, per the issue: package versions, .github/workflows/release.yml, PRs #155 and #156.
6. Open questions
- Baseline source of truth: keep a duplicate
baselines.pyguarded by the parity test, or refactorbenchmarks/guards/run.pyso both import one module? The first is smaller; the second removes drift risk. - Pyodide and sqlglot availability: does the existing playground already load sqlglot and the sqlguardllm package in Pyodide, at what version, and is the policy shape reusable for L3/L4? I couldn't see
playground/engine.pyorapp.js. - Mode versus page: the issue allows either. I proposed a separate page; confirm.
- Reporting channel wording: is GitHub private vulnerability reporting enabled on the repo today, and should the instructions name a fallback contact if it's disabled?
- Hall of fame format: table columns, and whether reporters can opt for anonymity.
- Query cost cap: is a step/row cap acceptable for the in-browser executor, and what limit?
- Dialect: assume SQLite for all levels [A]; confirm no other dialect is wanted for L3/L4.
- Fragment contents: is
levelplusresultenough, or should it also encode a locale?
Activity
jmmana commentedon Nov 30, 2026
/warcodex proveedor=claude cuenta="Warlock"
jmmana commentedon Nov 30, 2026
WarCodex: encolado, posición 1.
jmmana commentedon Nov 30, 2026
WarCodex: empezó a trabajar en este issue (intento 1).
jmmana commentedon Nov 30, 2026
WarCodex abrió un PR para esta issue: pendiente de revisión.
Base:
main· rama:warcodex/issue-181jmmana commentedon Nov 30, 2026
WarCodex: PR abierto: #184
5 remaining items
jmmana commentedon Nov 30, 2026
WarCodex: Bloqueada — la tarea quedó bloqueada.
Motivo: El CI del PR #184 vuelve a fallar con el mismo error tras la vuelta de CI 1: hace falta una decisión (corregirlo a mano, reintentar o cerrar).
Qué hacer: Revisa el detalle en el panel y, cuando esté resuelto, reintenta desde el panel.
Detalle de la tarea en el panel: https://warcodex.warlockcode.com/cola/38d21069-ed68-4557-bfb4-3b1d99d01b79
style: apply ruff format (#181)
fix(challenge): new secret per attempt; follow the bench package move (…
DIST-018 — Public challenge in the playground: break the firewall (#181…
jmmana commentedon Nov 30, 2026
WarCodex: listo, PR fusionado: #184
ci(docs): ship playground/challenge in the Pages site (#181) (#187)
jmmana commentedon Nov 30, 2026
Delivered in #184 (merged) and #187 (the Pages deploy did not include
playground/challenge/; fixed and verified).Verified live in a real browser at https://jmmana.github.io/sqlguardllm/playground/challenge/ (HTTP 200; levels.json and engine.py 200; Hall of fame https://jmmana.github.io/sqlguardllm/HALL_OF_FAME/ 200): the four levels load; the known L1 solution (
SELECT adjust_balance(1, 50)) wins; on L3 the literal secret from levels.json does not win andSELECT token FROM vaultis rejected withhidden_column; on L4SELECT ssn FROM clientsis rejected withhidden_column.A Sonnet 5.5 review before merging found one blocker (the L3/L4 secrets were static in levels.json, so typing the literal won): fixed with a per-attempt secret and tests (f1473ed). All PR checks green. Follow-ups not blocking (reviewer's should-fix list): error handling around the validate call, a stronger L3/L4 attack test, 360 px check with a win panel, and a request-recording test. Closing because every acceptance criterion is met.
DIST-018 — Public challenge in the playground: break the firewall (#181…
ci(docs): ship playground/challenge in the Pages site (#181) (#187)