Security: no runbook command or query identifies top pools by TVL or liquidity during incident [SEC-G03] #436

Closed
opened 2026-06-29 16:10:18 +00:00 by totdking · 8 comments
totdking commented 2026-06-29 16:10:18 +00:00 (Migrated from gitlab.com)
No description provided.
totdking commented 2026-06-29 16:10:57 +00:00 (Migrated from gitlab.com)

Summary

No runbook includes a command, SQL query, or API call that returns CL8Y DEX pairs sorted by approximate TVL or quote liquidity. During an incident, an operator needs to quickly identify which pools have the most value at risk. The incident triage template (incident-dex-indexer.md) does not include this query. None of the operational runbooks (emergency-commands.md, blacklist-decision.md, indexer-reorg-replay-dedup.md) include a pair ranking query.


What Was Checked

  • docs/templates/incident-dex-indexer.md: triage section checks contract pause state and tx codes. No query to rank pools by value.
  • docs/runbooks/emergency-commands.md: contains pause/blacklist commands per pair address. Requires the operator to already know which pair to target. No pool ranking query.
  • docs/runbooks/blacklist-decision.md: decision tree by scope, not by pool value ranking.
  • docs/integrators.md: lists indexer API endpoints. No specific runbook command to sort pairs by TVL or liquidity.

Expected (per checklist)

A runbook must include a command or query (SQL against the indexer DB, or an indexer API call) that returns all pairs sorted by descending approximate TVL or quote asset liquidity. This allows an operator to prioritize which pools to investigate or protect first during an incident.


Actual

No such command or query exists in any runbook. During an active incident, an operator would have to either query the frontend or construct a DB query without guidance.


Evidence

  • docs/templates/incident-dex-indexer.md: no pool-ranking query in triage section
  • docs/runbooks/emergency-commands.md: requires $PAIR_ADDR to already be known, no discovery step
  • No runbook lists a pair-ranking query

Suggested Fix

Add a "Quick pool triage" section to docs/templates/incident-dex-indexer.md or docs/runbooks/emergency-commands.md with a SQL snippet or indexer API call that returns pairs sorted by descending reserve value. Example: SELECT pair_address, asset_0_reserve, asset_1_reserve FROM pairs ORDER BY (asset_0_reserve + asset_1_reserve) DESC LIMIT 10; (adjusted for actual schema). If the indexer API has a pairs endpoint that includes reserve values, document that call with the sort parameter.


Verification Checklist

  • A runbook includes a SQL snippet or API call that returns pairs sorted by approximate TVL or quote liquidity in descending order
  • The query is present in the incident template triage section or in emergency-commands.md

Labels

security, pre-launch

Cc: @PlasticDigits

### Summary No runbook includes a command, SQL query, or API call that returns CL8Y DEX pairs sorted by approximate TVL or quote liquidity. During an incident, an operator needs to quickly identify which pools have the most value at risk. The incident triage template (`incident-dex-indexer.md`) does not include this query. None of the operational runbooks (`emergency-commands.md`, `blacklist-decision.md`, `indexer-reorg-replay-dedup.md`) include a pair ranking query. --- ### What Was Checked - `docs/templates/incident-dex-indexer.md`: triage section checks contract pause state and tx codes. No query to rank pools by value. - `docs/runbooks/emergency-commands.md`: contains pause/blacklist commands per pair address. Requires the operator to already know which pair to target. No pool ranking query. - `docs/runbooks/blacklist-decision.md`: decision tree by scope, not by pool value ranking. - `docs/integrators.md`: lists indexer API endpoints. No specific runbook command to sort pairs by TVL or liquidity. --- ### Expected (per checklist) A runbook must include a command or query (SQL against the indexer DB, or an indexer API call) that returns all pairs sorted by descending approximate TVL or quote asset liquidity. This allows an operator to prioritize which pools to investigate or protect first during an incident. --- ### Actual No such command or query exists in any runbook. During an active incident, an operator would have to either query the frontend or construct a DB query without guidance. --- ### Evidence - `docs/templates/incident-dex-indexer.md`: no pool-ranking query in triage section - `docs/runbooks/emergency-commands.md`: requires `$PAIR_ADDR` to already be known, no discovery step - No runbook lists a pair-ranking query --- ### Suggested Fix Add a "Quick pool triage" section to `docs/templates/incident-dex-indexer.md` or `docs/runbooks/emergency-commands.md` with a SQL snippet or indexer API call that returns pairs sorted by descending reserve value. Example: `SELECT pair_address, asset_0_reserve, asset_1_reserve FROM pairs ORDER BY (asset_0_reserve + asset_1_reserve) DESC LIMIT 10;` (adjusted for actual schema). If the indexer API has a pairs endpoint that includes reserve values, document that call with the sort parameter. --- ### Verification Checklist - [ ] A runbook includes a SQL snippet or API call that returns pairs sorted by approximate TVL or quote liquidity in descending order - [ ] The query is present in the incident template triage section or in `emergency-commands.md` --- ### Labels `security`, `pre-launch` Cc: @PlasticDigits
totdking commented 2026-06-29 16:15:51 +00:00 (Migrated from gitlab.com)

mentioned in issue #381

mentioned in issue #381
PlasticDigits commented 2026-06-30 02:22:52 +00:00 (Migrated from gitlab.com)

mentioned in merge request !968

mentioned in merge request !968
Brouie commented 2026-06-30 02:59:06 +00:00 (Migrated from gitlab.com)

Verified #436 at the docs + live-query layer (issue-436-pool-triage-sec-g03).

Guard: check_pool_triage_docs.py -> OK; verify-issue-436.sh -> PASS 4 / SKIP 1 (the SQL smoke skips in a bare checkout with no env file — ran it by hand against the live indexer instead).

Documented blocks, run live:

  • reserve-ranking SQL -> sorts desc by approx_liquidity_units (LUNC-C/EMBER 212,363 down to RUBY/TOPAZ 154,614; every column resolves)
  • quote-side SQL -> desc by quote_reserve_human (COBALT 147,581 down)
  • volume API /api/v1/pairs?sort=volume_24h&order=desc -> items desc by volume_quote_24h (OPAL/AMBER 211,043,516,471 first)

Both checklist items map: the desc-ranked SQL/API lives in emergency-commands.md "Quick pool triage (SEC-G03)" and the incident-template triage links it.

Docs + indexer SQL only, no redeploy. Good to close from my side — @PlasticDigits merge !968 + close.

Verified #436 at the docs + live-query layer (issue-436-pool-triage-sec-g03). Guard: check_pool_triage_docs.py -> OK; verify-issue-436.sh -> PASS 4 / SKIP 1 (the SQL smoke skips in a bare checkout with no env file — ran it by hand against the live indexer instead). Documented blocks, run live: - reserve-ranking SQL -> sorts desc by approx_liquidity_units (LUNC-C/EMBER 212,363 down to RUBY/TOPAZ 154,614; every column resolves) - quote-side SQL -> desc by quote_reserve_human (COBALT 147,581 down) - volume API /api/v1/pairs?sort=volume_24h&order=desc -> items desc by volume_quote_24h (OPAL/AMBER 211,043,516,471 first) Both checklist items map: the desc-ranked SQL/API lives in emergency-commands.md "Quick pool triage (SEC-G03)" and the incident-template triage links it. Docs + indexer SQL only, no redeploy. Good to close from my side — @PlasticDigits merge !968 + close.
PlasticDigits commented 2026-06-30 06:09:32 +00:00 (Migrated from gitlab.com)

mentioned in commit f28cdd4d52

mentioned in commit f28cdd4d528882e1e93b49ea59a81f05af5f88c9
PlasticDigits commented 2026-06-30 06:09:38 +00:00 (Migrated from gitlab.com)

mentioned in merge request !969

mentioned in merge request !969
PlasticDigits commented 2026-06-30 06:17:21 +00:00 (Migrated from gitlab.com)

mentioned in merge request !970

mentioned in merge request !970
PlasticDigits commented 2026-06-30 06:56:35 +00:00 (Migrated from gitlab.com)

Verification — #436 (SEC-G03 pool triage)

Verified on main after merge of !968 (7f1429d8). No repo changes required from this pass.

Acceptance checklist

Criterion How verified Result
Runbook includes SQL or API returning pairs sorted by approximate TVL/liquidity (desc) docs/runbooks/emergency-commands.md § Quick pool triage (SEC-G03) — reserve SQL ORDER BY approx_liquidity_units DESC, quote-side SQL ORDER BY quote_reserve_human DESC, API GET /api/v1/pairs?sort=volume_24h&order=desc PASS
Query present in incident template triage or emergency-commands.md docs/templates/incident-dex-indexer.md triage links emergency-commands.md#quick-pool-triage-sec-g03; runbook section present PASS

Automated / guard

Check Command Result
Doc invariant make check-pool-triage-docs PASS
Full ladder make verify-issue-436 PASS (5 PASS / 0 FAIL / 0 SKIP)
Agent skill skills/AGENTS_POOL_TRIAGE.md PASS
Cross-links docs/security-model.md, skills/AGENTS_EMERGENCY_COMMANDS.md PASS

Live query (manual)

Check How Result
Reserve-ranking SQL make setup-indexer-postgres → sqlx migrate run → runbook SQL via docker compose exec postgres psql PASS — query executes against pair_reserves schema; 0 rows (Postgres-only, no LocalTerra deploy)
Quote-side SQL Same session, quote-side block from runbook PASS — executes; 0 rows
Volume API live curl …/api/v1/pairs?sort=volume_24h&order=desc SKIP — indexer HTTP not running on this VM (no make setup-cloud-localterra). Documented call matches prior verification on deployed stack (see @Brouie note 2026-06-30).

Closing — implementation merged and docs/guards green.

## Verification — #436 (SEC-G03 pool triage) Verified on `main` after merge of !968 (`7f1429d8`). No repo changes required from this pass. ### Acceptance checklist | Criterion | How verified | Result | |-----------|--------------|--------| | Runbook includes SQL or API returning pairs sorted by approximate TVL/liquidity (desc) | `docs/runbooks/emergency-commands.md` § **Quick pool triage (SEC-G03)** — reserve SQL `ORDER BY approx_liquidity_units DESC`, quote-side SQL `ORDER BY quote_reserve_human DESC`, API `GET /api/v1/pairs?sort=volume_24h&order=desc` | **PASS** | | Query present in incident template triage or `emergency-commands.md` | `docs/templates/incident-dex-indexer.md` triage links `emergency-commands.md#quick-pool-triage-sec-g03`; runbook section present | **PASS** | ### Automated / guard | Check | Command | Result | |-------|---------|--------| | Doc invariant | `make check-pool-triage-docs` | **PASS** | | Full ladder | `make verify-issue-436` | **PASS** (5 PASS / 0 FAIL / 0 SKIP) | | Agent skill | `skills/AGENTS_POOL_TRIAGE.md` | **PASS** | | Cross-links | `docs/security-model.md`, `skills/AGENTS_EMERGENCY_COMMANDS.md` | **PASS** | ### Live query (manual) | Check | How | Result | |-------|-----|--------| | Reserve-ranking SQL | `make setup-indexer-postgres` → `sqlx migrate run` → runbook SQL via `docker compose exec postgres psql` | **PASS** — query executes against `pair_reserves` schema; 0 rows (Postgres-only, no LocalTerra deploy) | | Quote-side SQL | Same session, quote-side block from runbook | **PASS** — executes; 0 rows | | Volume API live | `curl …/api/v1/pairs?sort=volume_24h&order=desc` | **SKIP** — indexer HTTP not running on this VM (no `make setup-cloud-localterra`). Documented call matches prior verification on deployed stack (see @Brouie note 2026-06-30). | Closing — implementation merged and docs/guards green.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-06-30 06:56:36 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#436
No description provided.