Skip to content

fix(auth): the email whitelist takes an interactive admin, not a machine key (abilityai/trinity-enterprise#717) - #3935

Merged
vybe merged 2 commits into
devfrom
AndriiPasternak31/ent717
Oct 26, 2026
Merged

vybe merged 2 commits into
devfrom
AndriiPasternak31/ent717

Conversation

@AndriiPasternak31

Copy link
Copy Markdown
Contributor

Refs abilityai/trinity-enterprise#717

Require a signed-in admin session for POST /api/settings/email-whitelist, including entries whose first-sign-in role is user. Previously, an admin’s user-scoped key or the system key could authorize an address that later obtained an independent interactive session.

The route uses the existing INTERACTIVE dependency before reading the body and retains its admin check. Signed-in admins keep the existing success responses, duplicate wording, existing-account note and validation reasons. The shared admin gate is unchanged.

Remove the route from the frozen census baseline and pin its classification as INTERACTIVE. Add real-router tests for machine scopes, unknown/missing scope, malformed bodies and session controls. A loopback JWT carrying a vouched source agent is refused by the route gate; every loopback JWT is refused on this route by the entry fence, with a real-authentication regression test for the shape without a source agent.

Validation:

Check Result
New suite on unmodified dev (fix absent) 23 failed / 85: user and system keys answered 200 where 403 is expected (10), 422 instead of 403 on invalid bodies (8), vouched loopback 200 (5)
New suite + 9 related suites (route census, admin gate, machine identities, role-change audit, whitelist grant and validation, settings package, human-only principals), seeds 12345 and 4242 346 passed each
Backend unit tier, CI's command on Python 3.13.7 (clean snapshot: no .env, no submodules), seed 12345 27952 passed, 0 failed, 0 errors (test_ent717_whitelist_session_only 85, test_2996_human_only_routes 67)
Route census baseline 348 → 347 entries, exactly this route removed; INTERACTIVE pin added
lint_sys_modules (130 ≤ 131), lint_root_test_placement, git diff --check clean

The local runs above other than the 3.13 row used Python 3.14.4; CI pins 3.13, which the 3.13 row covers. A local full unit-island diff against unmodified dev (seed 12345, 3.14.4) showed 0 failures or errors only on this branch. Across the cross-branch Python 3.13 run the only red is a pre-existing timing flake on unmodified dev (test_ent879_aauth_resource_route, seed 67890; 8 of 2000 isolated repeats fail), on no branch.

Mutation (scratch copy; new suite + test_2996_human_only_routes + test_3455_email_whitelist_validation + test_837_whitelist_grant, 200 tests): route gate back to get_current_user → 25 failed / 200; assert_admin removed → 2 failed / 200; INTERACTIVE weakened to PERSON → 10 failed / 200; baseline entry not removed → 1 failed / 200.

Not run: Docker and the production-image stack check.

Matching private work remains pending. This PR does not close the tracking issue.

Journey Impact: none — existing whitelist behavior for signed-in admins is preserved; regression tests cover the tightened credential requirement.

…ine key (Abilityai/trinity-enterprise#717)

Adding an address to the whitelist grants an account, so the route is human-only: it takes require_interactive before body parsing. Every MCP key scope, missing scope, MFA and portal tokens and the loopback shapes are refused with 403; an interactive admin keeps the same responses. Route census baseline drops by one.

@dolho dolho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The change is tight and well evidenced.

Validation summary

  • Lane B; all Tier 1 checks green, plus journey-smoke and prod-image-smoke.
  • Re-ran the new suite with test_2996_human_only_routes, test_3455_email_whitelist_validation and test_837_whitelist_grant: 200 passed.
  • Mutation confirmed: reverting the route gate to get_current_user turns 25 tests red, matching your figure.
  • Secret, host-path and enterprise-docs greps are clean; requirements, architecture and feature-flow docs are updated consistently.
  • The only other whitelist writer (/api/access/request self-signup) is off by default and limited to user, so it is correctly out of scope.

Non-blocking notes

  1. The PR uses Refs rather than a closing keyword, which is right given the pending private work. ent#717 will need a manual move to status-in-dev after merge.
  2. The feature flow says the role-change route "has the same rule". update_user_role calls reject_non_interactive_principal directly and does not perform require_interactive's vouched-loopback refusal (the entry fence covers it). Consider wording it as "an equivalent interactive-only rule".
  3. As the updated flow now notes, adding a whitelist entry writes no audit event, while role changes are audited. That may be worth a follow-up issue, since an entry can pre-authorise an admin sign-in.

Approving.

@vybe
vybe merged commit 26b6601 into dev Oct 26, 2026
25 checks passed
webmixgamer added a commit that referenced this pull request Oct 26, 2026
Conflicts:
- docs/memory/architecture/security.md: dev (#3935) extended the "two human-only
  rules" paragraph; kept dev's paragraph with this branch's class rename
  (agent_callable -> agent_callable_self / agent_callable_any), then the
  self-gate paragraph.
- docs/memory/feature-flows.md: both sides added an index row; kept both,
  newest first.
- tests/unit/_route_census.py: both sides removed baseline rows (17 here, the
  whitelist add in #3935); FROZEN_BASELINE_COUNT = 330, the merged baseline's
  exact size.

Checked: #3913's routers/a2a.py change is inbound-path attribution; both outbound
handlers still open with assert_own_agent and keep the switch dependency, and no
new hand-copied self-gate arrived.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

3 participants