Skip to content

fix(security): permit fail-closed + ban http API keys + pin rust-toolchain - #211

Merged
echobt merged 3 commits into
mainfrom
cursor/security-permit-http-pin-0efe
Sep 4, 2026
Merged

fix(security): permit fail-closed + ban http API keys + pin rust-toolchain#211
echobt merged 3 commits into
mainfrom
cursor/security-permit-http-pin-0efe

Conversation

@echobt

@echobt echobt commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Security hotfix on main after #210. Three focused fail-closed changes only. Does not merge.

Summary

  1. Permit map fail-closed (chain-live)ValidatorPermit read or SCALE-decode errors now fail metagraph_at instead of substituting an empty vec. Missing storage, RPC faults, truncated bytes, and a decoded map whose length does not match hotkeys all fail closed. An empty map used to look like “no UID is a validator”, which would let a pure burn/vector through. Validator submit already skips when metagraph fetch fails.

  2. ctx keyed calls are HTTPS-onlyX-Lium-Api-Key is never attached on http://. Constructing a client with a key and a cleartext gateway fails with a clear error that does not echo the key. http:// without a key remains allowed for local stacks.

  3. release-ctx.yml pins dtolnay/rust-toolchain to commit d1031067263f94b142dd6c0ce24c5eb9d02d52a0 (never @master under contents: write).

No Modal. No secrets in git.

Greptile

Every PR is reviewed by Greptile before merge. Config: .greptile/.

  • Greptile has reviewed this PR; findings are fixed or answered
  • If the bot is silent, I commented @greptileai review

Test plan

  • cargo test -p chain-live --lib (59 passed, ignored live testnet)
  • cargo test -p ctx (30 passed)
  • cargo fmt --all -- --check
  • cargo clippy -p chain-live -p chain -p ctx --all-targets -- -D warnings
  • cargo run -p xtask -- loc-cap

Risk

Live validators skip set_weights / timelocked submit when ValidatorPermit cannot be read or decoded, instead of submitting a vector that could pay a validator UID. ctx miners using --gateway http://... together with LIUM_API_KEY must switch to HTTPS.

Naming

I did not rename BASE_* environment variables, deployed host paths (/opt/base, /run/base, …), GHCR baseintelligence/base package names, or base-*-v1 cryptographic domain tags.

Open in Web Open in Cursor 

cursoragent and others added 2 commits September 4, 2026 08:38
…chain

Permit fetch/decode errors now fail metagraph_at instead of an empty map
that would let a pure vector through. ctx refuses X-Lium-Api-Key on
http://. release-ctx pins dtolnay/rust-toolchain by commit SHA.

Co-authored-by: Mathis <echobt@users.noreply.github.com>
Co-authored-by: Mathis <echobt@users.noreply.github.com>
@echobt

echobt commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Review (Développeur) — LGTM on the three #210 P1s; cannot APPROVE via API (PR authored as echobt).

  1. ValidatorPermit: missing / RPC / decode / len ≠ hotkeys fail closed — empty map can no longer look like “no validators” and let a pure burn through. Tests cover the fail paths.
  2. ctx: construction + send refuse X-Lium-Api-Key on http://; key not echoed in errors; cleartext without key still ok for local.
  3. release-ctx.yml: dtolnay/rust-toolchain@d103106… verified (real commit, not @master under contents: write).

HOLD: do not ship gateway/validator images to cortex-production until this merges with CI + Greptile green.

@echobt

echobt commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai review

@echobt
echobt marked this pull request as ready for review September 4, 2026 08:43
@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown

Greptile Summary

The client rejects configured cleartext gateways when an API key is present, but automatic redirects can still send that key to a cleartext destination. This must be addressed before merging.

Confidence Score: 3/5

Not safe to merge: keyed requests can disclose API keys when a gateway redirects to HTTP.

A reproduced security failure affects the complete request path after the initial gateway URL check.

Files Needing Attention: bins/ctx/src/api.rs needs an HTTPS-only redirect policy or must disable redirects for keyed requests.

Security Review

A keyed request to an HTTPS gateway can be redirected to an HTTP URL. The current client follows that redirect and transmits X-Lium-Api-Key to the cleartext target.

T-Rex T-Rex Logs

What T-Rex did

  • Presented a proof for a P1 finding showing the API key was leaked via the keyed HTTP redirect before the fix and that the redirect now returns without contacting the target after the fix, supported by the before/after logs and the local probe source.
  • Validated the contract behavior around the keyed HTTP redirect: before evidence shows client 200 OK, source 302 Found, target 200 OK with the key present, and after evidence shows a 302 redirect with no contact to the target.
  • Posted an additional P1 finding via review comment.

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (1)

  1. General comment

    P1 Default redirect policy forwards the keyed request to an HTTP redirect target

    • Bug
      • The API client accepts an HTTPS base URL with X-Lium-Api-Key, but its default reqwest redirect policy automatically follows redirects. The executed local runtime probe showed the keyed request reached the HTTP redirect target: source returned 302 Found, target returned 200 OK, and TARGET_REQUEST_HAS_KEY=true. This violates the stated HTTPS-only handling for keyed requests.
    • Cause
      • bins/ctx/src/api.rs original lines 82-85 builds reqwest with its default redirect policy and neither disables redirects nor validates each redirect destination scheme before the request is resent.
    • Fix
      • Configure the client with .redirect(reqwest::redirect::Policy::none()) as applied, then return the redirect response rather than automatically following a potentially cleartext location. If redirect support is required later, resolve and validate every Location as HTTPS before issuing a new keyed request.

    T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "fix(ctx): fail-closed http API-key tests..." | Re-trigger Greptile

Comment thread bins/ctx/src/api.rs
reqwest follows redirects by default and resends headers to Location,
including http://. Keyed gateway calls now use Policy::none() so a 302
cannot put the API key on cleartext. Regression test: 302 to a second
origin is returned and the target is never contacted.

Co-authored-by: Mathis <echobt@users.noreply.github.com>
@echobt
echobt merged commit fb6f42e into main Sep 4, 2026
4 checks passed
@echobt
echobt deleted the cursor/security-permit-http-pin-0efe branch September 4, 2026 09:13
echobt added a commit that referenced this pull request Sep 4, 2026
Rebase of #207 onto main post #210/#211. Live catalog stays bounty+proof.
ctx relearn|image|agent remain for local stacks and print an off warning.
xtask now pins DEFAULT_GATEWAY from the binary and refuses miner-doc
placeholders and operator env names.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Mathis <echobt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants