security(indexer): isolate pair rejection caches and bound discovery pollution #1394

Closed
opened 2026-10-04 12:38:20 +00:00 by PlasticDigits · 2 comments
Owner

Summary and severity

Medium test reliability and conditional availability. Shared address-only rejection state contaminates independent contexts and causes reproduced nondeterministic tests, while churn increases discovery work.

Internal review references: SBHIGH-11/12; KIMIK3 TST-04; chain R. Investigated against source revision 748579ab718026efad54afcef4b2a5186fe82662 on 2026-10-04. These are engineering findings, not third-party audit certification. Only technical findings and synthetic test cases are included; no conversation, user identity, credentials or real-user activity is published.

Current codebase and evidence

Pair reject cache is process-global, keyed solely by address, retained for one hour and capped at 10,000 entries. Tests clear this shared state and reuse ATTACKER_PAIR across separate mock LCDs. A rejection from one LCD/factory therefore can suppress a legitimate lookup in another context. Cache insertion/lookup scans retained entries and eviction scans oldest entries, so adversarial foreign events can churn the cache and amplify LCD work.

Reproduced on this revision: eight default-parallel cargo test --lib discover_new_pair runs produced six passes and two failures, each with one failed/one passed test. Serial baseline lib tests passed 470. Runtime pollution needs attacker-controlled discovery triggers/events; the flaky assertion itself is not a runtime theft bug.

Why a new implementation is needed

Shared address-only rejection state contaminates independent contexts and causes reproduced nondeterministic tests, while churn increases discovery work.

Constraints and guardrails

  • Do not accept unlisted pairs or hide discovery failures to make tests pass. Preserve authoritative factory provenance.
  • Do not reset another test's/global production cache or rely only on serializing the full test suite.
  • Do not claim that 10,000 discovery events are unauthenticated HTTP requests unless a public trigger is demonstrated.

Relevant files

  • Scope cache by attested chain/LCD namespace plus factory and address; inject an isolated cache/clock into tests.
  • Use bounded efficient expiry/eviction, address validation and discovery work admission; avoid full-map scans on every lookup.
  • Keep transient LCD failures distinct from permanent provenance rejections and emit bounded-cardinality metrics.

Acceptance criteria

  • One LCD/factory rejection cannot suppress a different namespace's legitimate pair.
  • Parallel discovery tests are deterministic without shared clears/fixture collisions.
  • Cache remains memory/work bounded under churn, and known foreign pairs still avoid repeated factory queries.
  • Transient timeout/failover never poisons a long-lived negative entry; exact cache outcome/error types remain observable.

Test plan: supported and failure paths

  • Test same address on two namespaces/factories, listing/reject outcomes, expiration, capacity eviction, endpoint changes and clock advancement.
  • Run the two focused tests repeatedly with default and high parallelism, full cargo test --lib and relevant Postgres discovery tests.
  • Benchmark hot lookups and capacity churn; assert factory call counts, memory ceiling and fairness.

Test plan: attack, hack and abuse vectors

  • Synthetic foreign-event flood, invalid Bech32/address inputs, repeated swaps from one rogue contract and rotating foreign addresses.
  • Concurrent clear/insert/lookup and timeout/failover races must not suppress valid provenance checks or saturate an unrelated namespace.
  • Metric/log labels must not become an unbounded per-address memory sink.

Verification criteria

  • Actual reproduction: 2 failures in 8 runs on 2026-10-04, versus serial 470/470 passing baseline.
  • Require repeated parallel zero-failure receipts, cross-namespace regression and bounded capacity benchmark; no production discovery flood was run.
    Record revision, UTC time, exact commands, outcomes and evidence scope. Complete runnable checks first. Unavailable signing, deployment, device or infrastructure checks must be explicitly recorded as unverified; they do not block filing or implementation. An executed failure remains FAIL. Never claim deployment acceptance from unit tests or read-only probes. Public receipts must use synthetic identities and omit secrets.

1389: reverse-budget, 1400: ci-supply-chain. Each report owns its stated acceptance scope.

## Summary and severity Medium test reliability and conditional availability. Shared address-only rejection state contaminates independent contexts and causes reproduced nondeterministic tests, while churn increases discovery work. Internal review references: SBHIGH-11/12; KIMIK3 TST-04; chain R. Investigated against source revision `748579ab718026efad54afcef4b2a5186fe82662` on 2026-10-04. These are engineering findings, not third-party audit certification. Only technical findings and synthetic test cases are included; no conversation, user identity, credentials or real-user activity is published. ## Current codebase and evidence Pair reject cache is process-global, keyed solely by address, retained for one hour and capped at 10,000 entries. Tests clear this shared state and reuse ATTACKER_PAIR across separate mock LCDs. A rejection from one LCD/factory therefore can suppress a legitimate lookup in another context. Cache insertion/lookup scans retained entries and eviction scans oldest entries, so adversarial foreign events can churn the cache and amplify LCD work. Reproduced on this revision: eight default-parallel cargo test --lib discover_new_pair runs produced six passes and two failures, each with one failed/one passed test. Serial baseline lib tests passed 470. Runtime pollution needs attacker-controlled discovery triggers/events; the flaky assertion itself is not a runtime theft bug. ## Why a new implementation is needed Shared address-only rejection state contaminates independent contexts and causes reproduced nondeterministic tests, while churn increases discovery work. ## Constraints and guardrails - Do not accept unlisted pairs or hide discovery failures to make tests pass. Preserve authoritative factory provenance. - Do not reset another test's/global production cache or rely only on serializing the full test suite. - Do not claim that 10,000 discovery events are unauthenticated HTTP requests unless a public trigger is demonstrated. ## Relevant files - [indexer/src/indexer/pair_discovery.rs](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/indexer/src/indexer/pair_discovery.rs) - [indexer/src/lcd/mod.rs](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/indexer/src/lcd/mod.rs) - [.gitlab-ci.yml](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/.gitlab-ci.yml) - [indexer/src/indexer/mod.rs](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/indexer/src/indexer/mod.rs) ## Recommended direction - Scope cache by attested chain/LCD namespace plus factory and address; inject an isolated cache/clock into tests. - Use bounded efficient expiry/eviction, address validation and discovery work admission; avoid full-map scans on every lookup. - Keep transient LCD failures distinct from permanent provenance rejections and emit bounded-cardinality metrics. ## Acceptance criteria - [ ] One LCD/factory rejection cannot suppress a different namespace's legitimate pair. - [ ] Parallel discovery tests are deterministic without shared clears/fixture collisions. - [ ] Cache remains memory/work bounded under churn, and known foreign pairs still avoid repeated factory queries. - [ ] Transient timeout/failover never poisons a long-lived negative entry; exact cache outcome/error types remain observable. ## Test plan: supported and failure paths - Test same address on two namespaces/factories, listing/reject outcomes, expiration, capacity eviction, endpoint changes and clock advancement. - Run the two focused tests repeatedly with default and high parallelism, full cargo test --lib and relevant Postgres discovery tests. - Benchmark hot lookups and capacity churn; assert factory call counts, memory ceiling and fairness. ## Test plan: attack, hack and abuse vectors - Synthetic foreign-event flood, invalid Bech32/address inputs, repeated swaps from one rogue contract and rotating foreign addresses. - Concurrent clear/insert/lookup and timeout/failover races must not suppress valid provenance checks or saturate an unrelated namespace. - Metric/log labels must not become an unbounded per-address memory sink. ## Verification criteria - Actual reproduction: 2 failures in 8 runs on 2026-10-04, versus serial 470/470 passing baseline. - Require repeated parallel zero-failure receipts, cross-namespace regression and bounded capacity benchmark; no production discovery flood was run. Record revision, UTC time, exact commands, outcomes and evidence scope. Complete runnable checks first. Unavailable signing, deployment, device or infrastructure checks must be explicitly recorded as unverified; they do not block filing or implementation. An executed failure remains FAIL. Never claim deployment acceptance from unit tests or read-only probes. Public receipts must use synthetic identities and omit secrets. ## Related remediation reports [1389: reverse-budget](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1389), [1400: ci-supply-chain](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1400). Each report owns its stated acceptance scope.
Author
Owner

Merge sweep 2026-10-05: the two existing October 4 audit reports are being preserved on main with the sanity receipt. They document findings; committing them does not implement remediation.

Remaining implementation: Isolate pair rejection cache namespaces/test state and bound cache pollution. Serialized indexer library sanity passes (470 tests), but serialization does not repair the shared-cache design. This issue stays open for that substantive work, not merely a verification hold.

Merge sweep 2026-10-05: the two existing October 4 audit reports are being preserved on main with the sanity receipt. They document findings; committing them does not implement remediation. Remaining implementation: Isolate pair rejection cache namespaces/test state and bound cache pollution. Serialized indexer library sanity passes (470 tests), but serialization does not repair the shared-cache design. This issue stays open for that substantive work, not merely a verification hold.
Author
Owner

PR #1405 and the final integration PR #1423 are merged into main. Source acceptance: 944 contract tests + strict all-target Clippy, 858 indexer tests across 29 suites, and 3,093 frontend tests + lint/build. Fresh pinned optimizer verification passed. Full receipt.

The later chain-attestation integration initially bypassed admission for node-info calls. Admission was corrected and HTTP-work assertions pass; make verify-issue-1394 reports 23 PASS/0 FAIL/0 SKIP with default/high-thread repeats, churn benchmark and isolated Postgres retest.

CI was skipped by explicit operator instruction. Native wrap-stack and production execution remain explicitly unverified. Deployment/history/release work is transferred to #1421 and existing #1384/#1385/#1386; the default query-gas repair is #1422. The source issue is complete and carries no verification-only hold; closure does not claim production deployment.

PR #1405 and the final integration PR #1423 are merged into main. Source acceptance: 944 contract tests + strict all-target Clippy, 858 indexer tests across 29 suites, and 3,093 frontend tests + lint/build. Fresh pinned optimizer verification passed. [Full receipt](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-06/README.md). The later chain-attestation integration initially bypassed admission for node-info calls. Admission was corrected and HTTP-work assertions pass; make verify-issue-1394 reports 23 PASS/0 FAIL/0 SKIP with default/high-thread repeats, churn benchmark and isolated Postgres retest. CI was skipped by explicit operator instruction. Native wrap-stack and production execution remain explicitly unverified. Deployment/history/release work is transferred to #1421 and existing #1384/#1385/#1386; the default query-gas repair is #1422. The source issue is complete and carries no verification-only hold; closure does not claim production deployment.
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#1394
No description provided.