Skip to content

fix(orb): prevent OAuth self-enrollment from re-enabling operator-disabled installs - #1465

Merged
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-self-enrollment-vulnerability
Jun 26, 2026
Merged

fix(orb): prevent OAuth self-enrollment from re-enabling operator-disabled installs#1465
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-self-enrollment-vulnerability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a privilege/authorization bypass where a verified installation admin could revisit the OAuth callback and clear an operator opt-out by flipping registered back to 1 and obtaining a new enrollment secret.
  • Ensure operator-controlled revocation/disable remains authoritative and cannot be undone via the OAuth self-enrollment flow.

Description

  • Add a new installation column self_enrollment_disabled (migration 0074_orb_self_enrollment_disabled.sql) to separate operator disables from pending/unregistered installs.
  • Read self_enrollment_disabled in the Orb OAuth callback and block self-enrollment when it is set, returning a 403 and an explanatory landing page instead of auto-registering. (src/orb/oauth.ts)
  • Update the internal operator POST /v1/internal/orb/installations/register endpoint to set self_enrollment_disabled = 1 when opting out and clear it when opting back in, so operator actions persist as a distinct state. (src/api/routes.ts)
  • Add integration regression tests that cover: (a) operator-disable prevents OAuth re-enablement, and (b) the operator register endpoint toggles self_enrollment_disabled correctly while preserving the zero-touch flow for non-disabled pending installs. (test/integration/orb-oauth.test.ts, test/integration/orb-broker.test.ts)

Testing

  • Ran the relevant integration suites with npx vitest run test/integration/orb-oauth.test.ts test/integration/orb-broker.test.ts and they passed (2 files, 28 tests, 28 passed).
  • Ran migration sanity with npm run db:migrations:check and TypeScript typecheck with npm run typecheck, both succeeded.
  • Ran npm run ui:openapi:check, which succeeded on the committed spec check step; npm audit --audit-level=moderate failed due to the npm audit endpoint returning 403 Forbidden from the environment and is thus inconclusive.
  • Attempted the full coverage run npm run test:coverage but it failed outside the changed area due to long-running test timeouts and a coverage remapping error (TypeError: jsTokens is not a function), so full repo coverage could not be verified in this environment; the added integration tests exercise the new branches introduced by this change.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jun 26, 2026
@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jun 26, 2026
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.44%. Comparing base (8309b23) to head (d5a9e5c).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1465   +/-   ##
=======================================
  Coverage   95.44%   95.44%           
=======================================
  Files         194      194           
  Lines       21054    21055    +1     
  Branches     7619     7621    +2     
=======================================
+ Hits        20094    20095    +1     
  Misses        383      383           
  Partials      577      577           
Files with missing lines Coverage Δ
src/api/routes.ts 94.60% <100.00%> (ø)
src/orb/oauth.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit cae68eb into main Jun 26, 2026
19 checks passed
@JSONbored
JSONbored deleted the codex/propose-fix-for-self-enrollment-vulnerability branch June 26, 2026 20:38
JSONbored added a commit that referenced this pull request Jun 26, 2026
)

Both 0074_ai_review_cache (#1462) and 0074_orb_self_enrollment_disabled (#1465) merged
and deployed before the duplicate number surfaced. The latter is a bare ALTER TABLE ADD
COLUMN, which SQLite cannot guard with IF NOT EXISTS, and D1/self-host track applied
migrations by filename — so renaming it now would re-run the ALTER and fail the deploy.
Grandfather the pair (same rationale as the pre-existing 0015/0017 entries) so
db:migrations:check passes on main again; this unblocks validate on every open PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant