fix(orb): authenticate relay registration before body parse#1397
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1397 +/- ##
=======================================
Coverage 95.38% 95.38%
=======================================
Files 201 201
Lines 21598 21629 +31
Branches 7807 7816 +9
=======================================
+ Hits 20601 20631 +30
Misses 416 416
- Partials 581 582 +1
🚀 New features to boost your workflow:
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | f20438e | Commit Preview URL Branch Preview URL |
Jun 26 2026, 09:13 PM |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review — safe to merge
✅ Approved — safe to merge
Nits — 2 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Motivation
/v1/orb/relay/registerparsed an unbounded JSON body before validating the caller's enrollment secret.Description
MAX_ORB_RELAY_REGISTER_BODY_BYTESandreadOrbRelayRegisterBodyinsrc/orb/relay.tsto enforce a 4 KiB streamed body ceiling and aContent-Lengthpre-check.validateOrbRelayEnrollmentandregisterValidatedOrbRelayinsrc/orb/relay.ts, and refactorregisterOrbRelayto reuse them so enrollment validation can be done independently of body parsing.src/api/routes.tsto validate the enrollment secret first, short-circuit with401/403on invalid secrets, callreadOrbRelayRegisterBodyto enforce the size cap (returning413on overflow), and only then parse JSON and persist the relay URL.test/integration/orb-relay.test.tsto cover oversized registration payloads (413) and to assert that an invalid enrollment is rejected before any request-body access.Testing
npx vitest run test/integration/orb-relay.test.tsand the integration suite fororb-relaypassed (all tests in that file succeeded).npm run typecheckandgit diff --checkwhich succeeded with no type or diff errors.npm run ui:openapi:checkwhich completed successfully.npm run test:ci, but the run failed during coverage generation with an unrelated Vitest coverage provider error (TypeError: jsTokens is not a function), so the full CI/gate could not be completed locally;npm audit --audit-level=moderatealso failed due to an npm registry403 Forbiddenduring the audit request.Codex Task