Skip to content

fix(api): bind the v1 role guard to a verified agent token#228

Merged
rennf93 merged 1 commit into
masterfrom
fix/v1-role-token-binding
Jun 19, 2026
Merged

fix(api): bind the v1 role guard to a verified agent token#228
rennf93 merged 1 commit into
masterfrom
fix/v1-role-token-binding

Conversation

@rennf93

@rennf93 rennf93 commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Supersedes #222 — credit to antfleet-ops for flagging the bypass. Re-done as our own change so it lands without the contributor CLA, and adds the positive valid-token test their PR was missing.

The v1 flow role guards (_require_roles) are the sole gate for /api/v1/flow/* but checked only the X-Agent-Role string — unlike get_agent_context, which verifies the token. So a forged role header passed, and in strict mode (ROBOCO_AGENT_AUTH_REQUIRED) the token was never required here. Now calls _check_agent_auth_token before the role test: missing token stays a no-op in header-trust mode, any presented token is verified, strict mode requires it.

Once this merges, #222 should be closed with a link here.

The v1 flow role guards (_require_roles) are the sole gate for /api/v1/flow/*
but checked only the X-Agent-Role string — unlike get_agent_context, which
verifies the token. So a forged role header passed, and in strict mode
(ROBOCO_AGENT_AUTH_REQUIRED) the token was never required on these routes.
Call _check_agent_auth_token before the role membership test (deferred import
to avoid the cycle): missing token stays a no-op in header-trust mode, any
presented token is verified, and strict mode now requires it.

Supersedes #222 (antfleet-ops flagged the bypass); re-done as our own change so
it lands without the contributor CLA, and adds the positive valid-token test
their PR was missing.
@github-actions github-actions Bot added area: api Touches roboco/api/ (FastAPI routes, schemas, app) tests Test suite changes labels Jun 19, 2026
@github-actions

Copy link
Copy Markdown

Thanks for opening your first pull request on RoboCo!

Quick checklist before review (most of these are enforced by CI, but worth a glance):

  • make quality — ruff format check, ruff check, mypy, pytest (≥80% coverage), and the rest of the gate
  • Panel changes pass pnpm lint and pnpm exec tsc --noEmit (run from panel/)
  • No # noqa / # type: ignore shortcuts; pre-existing violations in touched files are fixed
  • Added an entry under ## [Unreleased] in CHANGELOG.md
  • Signed the CLA (the bot will prompt you on this PR)
  • Signed your commits — master requires verified signatures (SSH signing setup)
  • Updated any affected docs under docs/

See CONTRIBUTING.md for the full workflow and the Code of Conduct for the community standards we follow.

Welcome aboard — a maintainer will review shortly.

@rennf93 rennf93 merged commit 463c952 into master Jun 19, 2026
9 checks passed
@rennf93 rennf93 deleted the fix/v1-role-token-binding branch June 19, 2026 18:57
@github-project-automation github-project-automation Bot moved this from Backlog to Done in RoboCo Kanban Jun 19, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: api Touches roboco/api/ (FastAPI routes, schemas, app) tests Test suite changes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant