fix(#3): Harden ops security — auth /update_terms, ADMIN_TOKEN, redirect allowlist, trusted XFF #22
No reviewers
Labels
No labels
agent:implement
agent:ready
api
bot
bug
ci
enhancement
ready
security
terra-classic
testing
ux
web
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-ecosystem-legal!22
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-3-security-ops"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes the portal/API ops security bundle from issue #3 / gap items 4–7:
POST /update_termswithADMIN_TOKENBearer (POST-only; auth before 1 req/s limit)ADMIN_TOKEN(no silentdev-admin-token;ALLOW_INSECURE_DEFAULTSlocal opt-in)subtle) shared by admin + update_termsredirect_uriallowlist (VITE_REDIRECT_URI_ALLOWLIST/ localhost flag); SDKsanitizeRedirectUriTRUSTED_PROXY_CIDRSenables XFF (rightmost hop)GET /healthfor readiness (e2e/CI); docs +skills/security-ops/SKILL.mdTest plan
cd api && cargo test(unit + integration auth)/health→ okADMIN_TOKENset;TRUSTED_PROXY_CIDRSonly if behind reverse proxy; setVITE_REDIRECT_URI_ALLOWLISTfor real dapp originsAcceptance criteria (issue #3)
/update_terms→ 401; authenticated still syncsredirect_uri.env.example+ CI/e2e updatedCloses #3
RECOMMEND: ACCEPT
Thorough security + gap review of MR !22 (
fix/issue-3-security-ops→main,c40ea6e) against issue #3 / GAP items 4–7.Verdict
Issue #3 acceptance criteria are met in code. No critical/high defects or prompt-injection issues in the changed surface. Residual items are configuration hardening and test-depth follow-ups — not merge blockers for this scoped ops-security bundle.
Out of scope / no regression from this diff: DeFi attacks, smart-contract attacks, oracle manipulation, tokenomic/economic attacks (no on-chain contracts/oracles/tokenomics in repo or this MR). Pre-existing out-of-scope debt (Telegram HMAC, Solana/Terra verify, bot fail-open, open property auto-upsert) remains unchanged.
Issue #3 acceptance criteria
/update_terms→ 401; authenticated syncsapi/src/routes/update_terms.rs(POST-only,require_adminbefore rate limit + sync); deny paths inapi/tests/integration_test.rsapi/src/config.rsresolve_admin_token— missing/empty/dev-admin-tokenfail-fast unlessALLOW_INSECURE_DEFAULTSredirect_uriweb/src/ui.ts+sanitizeRedirectUri(SDK + portal)api/src/rate_limit.rspeer default;TRUSTED_PROXY_CIDRS+ rightmost hopapi/src/auth.rs(subtle::ConstantTimeEq); shared by admin + update_terms.env.example+ CI/e2e updated.gitlab-ci.yml, PlaywrightADMIN_TOKEN+/healthGAP items 4–7 marked Addressed in
gaps/GAP_1786322222.md— accurate for portal/API ops.Security audit (changed code)
/update_terms+/admin/*gated on shared Bearer; auth before ops rate limit (good)javascript:,data:,//, userinfo; origin match; deny-by-default when allowlist empty/healthinfo leak{status: ok}— OK for probesResidual (non-blocking)
.env.exampleshipsADMIN_TOKEN=change-me-admin-token; fail-fast only blocksdev-admin-tokenTRUSTED_PROXY_CIDRSaccepts0.0.0.0/0/::/0with no boot guardredirect_uri/update_terms→published/unchangedAttack / test matrix (issue #3)
/update_termsdev-admin-token)redirect_uri=https://evil.comjavascript:/data://// userinfoLocal test signal (review env): API unit tests pass; SDK Vitest 21/21; web Vitest 13/13; one unrelated integration fixture flake (
version_label=1.5duplicate) — not introduced as a security regression by this MR. Full Playwright not re-run here.Gap analysis (features / packages / quality)
api/auth.rs, fail-fast config, POST-only update_terms, XFF policy,/healthweb/packages/cl8y-clickwrapsanitizeRedirectUri; optional for headless integrators (documented)scripts/, CI, README,skills/security-opsbot/, contractsUser/operator expectations still open (follow-ups): blocked-redirect messaging;
/ready(DB) vs liveness-only/health;stateround-trip on redirect (GAP #13); staging env confirmation (MR checklist).Bottom line
Accept — closes the intended control-plane / open-redirect / XFF / default-token bundle for issue #3 with sound design and adequate automated coverage for deny paths. Please track the medium follow-ups (example-token denylist, world-CIDR guard, redirect e2e + sync happy-path test) as non-blocking hardening.
mentioned in issue #3
added 5 commits
74a80e65- Fix Terra Classic Keplr signing with ADR-036 verify.62d8d76c- Harden Terra ADR-036 CI, abuse tests, and portal invariants.6ec0af69- Stabilize Playwright e2e startup on CI.Compare with previous version
added 4 commits
03849d3b- 1 commit from branchmainb0725585- Harden portal/API ops security for issue #3.8294413c- Fix integration test Config after rebase onto Terra ADR-036.c5fdf1a3- Remove unused PrehashSigner import in integration tests.Compare with previous version
mentioned in issue #2
aborted the automatic merge because merge request was closed
mentioned in commit
8cf6527707Merged to
mainvia git merge (tipc5fdf1a) becauseglab mr mergewas blocked by CI quota (ci_quota_exceeded/ci_must_passafter canceled pipeline). Commit is onmain.