Skip to content

Check job tokens, caller roles and runner scope on Actions routes as GitHub does - #31

Merged
waynesun09 merged 5 commits into
mainfrom
emu-14-access-checks
Nov 19, 2026
Merged

waynesun09 merged 5 commits into
mainfrom
emu-14-access-checks

Conversation

@waynesun09

@waynesun09 waynesun09 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Part of #39

Access checks on job-server, Actions write and pool agent routes

This PR makes three groups of routes check what GitHub checks:

Routes GitHub checks The emulator checked Now
Job-server routes the runner calls with the job token A job token GitHub issued, for that job's plan and timeline The job id in the token's payload; the plan or timeline in the path chose the job The token's signature, issuer and lifetime (validate_job_token), and that the plan and timeline are the token's own
Actions write routes The caller's role on the repository That the caller is signed in Write or admin, as listed below
Pool agent list, update and remove The runner's own repository, organization or enterprise Every runner on the instance The runner's own scope

Each group has its own docs/bugs/fixed/ entry and PLAN.md line.

Changes

1. Job-server routes validate the job token

  • Routes: timeline records and feed, create and append log, action download info, and the action archive.
  • _job_from_token_value in src/app/api/actions_distributed_task.py now calls the existing validate_job_token (src/app/services/job_token_service.py). It checks the HS256 signature, the issuer and exp/nbf.
  • A token that fails gets 401 Invalid job token, including one whose header or payload is not a JSON object. The job's own token works as before.
  • _job_for_plan checks that the plan (the run) and timeline (the job) in the path are the token's own, from its job message, and answers 404 otherwise. The routes write only to the token's job, so two jobs of one run also keep their logs apart.

2. Actions write routes require the role GitHub documents

_require_repository_role in src/app/api/actions.py answers 403 unless the person holds the role:

Route Role 403 message Job token (GITHUB_TOKEN)
Workflow dispatch, run cancel, run re-run write Must have write access to this repository. its actions permission
Artifact upload and delete write same its actions permission
Actions variables (POST, PATCH, DELETE) write same 403
Actions secrets (PUT, DELETE) admin Must have admin rights to Repository. 403
PUT .../actions/permissions and .../permissions/workflow admin same 403
  • Admin means the owner for a personal repository. A site admin passes.
  • A GITHUB_TOKEN has no permission for secrets, variables or repository administration, so on those routes it gets 403 Resource not accessible by integration, as on GitHub.
  • An App installation token keeps the per-route permission checks it already gets at authentication.
  • Cancel now acts only on a run of the repository in its path. Another run id gets 404, as re-run already did.

3. Pool agent routes are scoped to the runner

  • On GitHub a self-hosted runner belongs to the repository, organization or enterprise it registered with, and its credential sees only the agents there.
  • _same_scope_as matches the caller's repo_id, org_id and enterprise_slug. dt_list_pool_agents, dt_update_pool_agent and dt_delete_pool_agent use it.
  • A runner outside the caller's scope is not listed, and updating or removing it gets 404. So config.sh --replace finds only the runner with that name in its own scope.

Tests

Every new test fails on main and passes with this PR.

File What it checks
tests/actions/test_job_token_routes.py (2 tests) Each job-server route and the action archive refuse a token with a bad signature, an unsigned token, a token with another issuer, an expired token, and tokens whose header or payload is not an object; the job's own token is still accepted
tests/actions/test_job_token_route_targets.py (2 tests) A job's token gets 404 on another run's plan and on another job's timeline in the same run; the other job's log stays empty
tests/test_actions_write_permissions.py (6 tests) Cancel by a user with no role, a reader and a writer; cancel of another repository's run; re-run by a reader; secrets and permissions by each role and the owner; variables by a writer, a reader and a user with no role; a job token with actions: write on secrets, variables and permissions, and on cancel
tests/actions/test_runner_agent_scope.py (1 test) Two repositories each register a runner with the same name; each runner lists only its own, and updating or removing the other's gets 404

Full suite: runs in this pull request's CI (ci.yml).

Effect on existing behaviour

  • A person without write access now gets 403 on dispatch, cancel, re-run, artifact writes and Actions variables. A person without admin access gets 403 on Actions secrets and permissions. Scripts or fixtures that used a personal token without the role need the owner's token, a collaborator with the role, or the seeded admin token.
  • A job's GITHUB_TOKEN can no longer change Actions secrets, variables or settings.
  • Job tokens the emulator issued keep working on their own job's plan and timeline. Installation tokens and runner credentials work as before.
  • Runners registered at different scopes no longer see each other's agents, even with the same name.

@waynesun09
waynesun09 requested a review from jctanner November 18, 2026 22:39
@qodo-code-review

qodo-code-review Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Enforce job-token, repository-role, and runner-scope checks

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Validate job tokens before serving runner job-server requests, rejecting forged or expired
 credentials.
• Require repository write or admin access for Actions mutations and restrict cancellation to the
 named repository.
• Limit pool-agent operations to the runner’s registration scope.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 6 capabilities

  • 6 affected capabilities span independent functional scopes: actions_repository_integration, actions_runner_job_integration, self_hosted_runner_management.
  • Dispatch, cancel, and rerun are distinct user operations but all control workflow execution for one repository integration.
  • The changed routes resolve the repository and run and apply the same repository-role policy; no separate independent functional scope is evidenced.
  • Secrets, default workflow permissions, and Actions enablement are separate repository-management operations, but they share the bounded Actions repository-configuration integration and the new admin/job-token gate.
  • They affect persistent repository configuration rather than a separate technical layer.
  • Artifact upload/deletion and repository variable writes are distinct Actions-management outcomes, but both are repository-scoped mutable resources governed by the same push-role integration policy.
  • They do not establish an independent functional scope from the other Actions repository operations.
  • Timeline records, console feeds, and job logs are separate delivery surfaces for the same runner-to-job reporting integration.
  • The token and plan/timeline binding is shared across those routes, so they are one bounded end-to-end reporting capability rather than separate technical-hop capabilities.
  • Action download-info resolution and archive retrieval are two hops of one runner action-download behavior.
  • The archive is produced from the download-info response and uses the job credential, so they share the same bounded runner integration.
  • Listing, replacement/update, and removal are distinct operator outcomes over the same self-hosted runner pool integration.
  • The new scope predicate is the common boundary for all three, and no separate functional scope is evidenced by their different HTTP methods.
Sources

src/app/api/actions_distributed_task.py[476-481]

    result = await db.execute(select(Runner).where(
        Runner.id == agent_id, _same_scope_as(authenticated_runner),
    ))
    runner = result.scalar_one_or_none()
    if runner is None:
        raise HTTPException(status_code=404, detail="Agent not found")
Behavioral complexity 🟡 Medium 🧩 Interacting branches, Coordinated invariants

  • Before: affected routes primarily relied on authentication and then performed their existing mutation.
  • After: each route must preserve a coordinated invariant between credential class, repository identity, route-specific push/admin role, job-token permissions, and mutation ordering.
  • New correctness condition: every route must apply the right role without bypassing legitimate installation/job-token behavior, and must do so before any persistent or workflow side effect.
  • The helper's set lookup is straightforward; the complexity comes from the interacting credential branches and the many route-specific consequences.
Potential damage 🔴 High 🩹 Integrity

  • A false allow could let a reader, outsider, or job token alter repository secrets or Actions settings.
  • Secrets may need rotation rather than merely restoring code; settings and workflow-permission changes may require explicit state repair.
  • A false deny is a recoverable administrative outage, but the worst credible activated failure is unauthorized persistent repository configuration.
  • Code rollback prevents further unauthorized writes but does not undo already-written secrets or settings.
  • Recovery may require restoring prior settings and rotating exposed secrets; no automatic compensating mechanism is shown.
Assessed commit f3b349f
Diagram

graph TD
  C["API Caller"] -->|job token| V["Token Validation"] --> J["Job Routes"]
  C -->|person credential| R["Repository Role"] --> A["Actions Writes"]
  C -->|runner credential| S["Runner Scope"] --> P["Pool Agents"]
Loading
High-Level Assessment

The approach reuses the existing job-token validator and repository-permission model while applying scope filters in agent queries. Reimplementing token validation or duplicating permission rules would add inconsistency without a clear benefit.

Files changed (9) +457 / -36

Bug fix (2) +91 / -36
actions.pyRequire repository roles on Actions mutations +59/-11

Require repository roles on Actions mutations

• Adds a shared role check requiring write access for workflow and artifact mutations and admin access for secrets, variables, and permissions changes. Restricts run cancellation to the repository named in the request path while preserving existing job and installation-token checks.

src/app/api/actions.py

actions_distributed_task.pyValidate job tokens and scope pool-agent queries +32/-25

Validate job tokens and scope pool-agent queries

• Replaces unverified job-token payload parsing with the existing validator for job-server and archive requests. Filters agent listing, update, and deletion to the authenticated runner’s registration scope.

src/app/api/actions_distributed_task.py

Tests (3) +272 / -0
test_job_token_routes.pyTest rejection of invalid job-server credentials +107/-0

Test rejection of invalid job-server credentials

• Exercises forged, unsigned, wrong-issuer, and expired tokens across job-server routes and the action archive. Also checks that the job’s issued token remains accepted on job-server routes.

tests/actions/test_job_token_routes.py

test_runner_agent_scope.pyTest isolation between repository runners +63/-0

Test isolation between repository runners

• Registers same-named runners in separate repositories and verifies scoped listing. Confirms that one runner cannot update or delete the other’s agent.

tests/actions/test_runner_agent_scope.py

test_actions_write_permissions.pyTest Actions write roles and run ownership +102/-0

Test Actions write roles and run ownership

• Checks write-role requirements for cancellation and re-run, admin-role requirements for selected settings mutations, and rejection of cross-repository cancellation.

tests/test_actions_write_permissions.py

Documentation (4) +94 / -0
PLAN.mdIndex three fixed Actions access-control bugs +3/-0

Index three fixed Actions access-control bugs

• Adds links to the job-token, Actions write-role, and runner-agent scope bug records.

PLAN.md

actions-write-routes-do-not-check-the-repository-role.mdDocument repository-role checks for Actions writes +42/-0

Document repository-role checks for Actions writes

• Records the affected routes, required roles, denial responses, and repository-bound cancellation behavior. Notes the chosen admin requirement for variables.

docs/bugs/fixed/actions-write-routes-do-not-check-the-repository-role.md

job-server-routes-do-not-validate-the-job-token.mdDocument the job-token validation fix +25/-0

Document the job-token validation fix

• Explains the former payload-only check, the reuse of token validation, and the expected unauthorized response.

docs/bugs/fixed/job-server-routes-do-not-validate-the-job-token.md

runner-agent-routes-are-not-scoped-to-the-runner.mdDocument runner-scoped pool-agent access +24/-0

Document runner-scoped pool-agent access

• Describes the former instance-wide agent access and the new repository, organization, and enterprise scope restriction.

docs/bugs/fixed/runner-agent-routes-are-not-scoped-to-the-runner.md

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 10:40 PM UTC · Completed 10:53 PM UTC

Commit: 4f9ae70 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $4.14

@qodo-code-review

qodo-code-review Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Any job's token can write another job's logs ✓ Resolved

Resolving commit: 724efda

Resolution reason
The post-finding commit replaces the plan/timeline lookup with _job_for_plan, which takes the job
from the authenticated token and answers 404 when the plan_id (and timeline_id, where given) in the
path does not match the token's own run/job. All timeline, feed and log handlers now write only to
the token's job, and the target-job lookup via _job_from_plan_id is removed. Tests cover a job token
posting to another run's plan and another job's timeline in the same run, matching the suggested
test. This differs from the suggested fix (it derives the target solely from the authenticated job
rather than cross-checking), but it addresses the same issue.
Description
_job_from_token_value now confirms the token is genuine, but the timeline, feed and log handlers
still pick the target job from plan_id/timeline_id (_job_from_plan_id,
_job_from_timeline_id) and use the authenticated job only as a fallback, without checking that the
two match. Plan ids are uuid5 values derived from the run id, so they are easy to predict. Any
workflow author already holds a valid job token (their own GITHUB_TOKEN), and with it they can
append log lines to, or rewrite timeline records of, a running job in any other repository, private
ones included.


Remediation recommended

2. Jobs running over an hour lose logs 🐞 Bug ☼ Reliability
Description
validate_job_token now enforces an expiry set by issue_job_token to one hour after pickup,
although the runner keeps the job-message token throughout execution and the old
_job_from_token_value did not check expiry. When a supported job runs longer than an hour, later
timeline updates, console feeds, log uploads, and action downloads receive 401, while the job can
still finish through its separate runner credential.
Code

src/app/api/actions_distributed_task.py[R377-379]

+    validated = await validate_job_token(db, token)
+    if validated is None:
        raise HTTPException(status_code=401, detail="Invalid job token", headers=challenge)
-    try:
-        job_id = int(subject.split(":", 1)[1])
-    except ValueError:
-        raise HTTPException(status_code=401, detail="Invalid job token", headers=challenge) from None
-
-    result = await db.execute(select(WorkflowJob).where(WorkflowJob.id == job_id))
-    job = result.scalar_one_or_none()
-    if job is None:
-        raise HTTPException(status_code=401, detail="Job token target not found", headers=challenge)
Evidence
Issuance sets the signed token’s expiry to 3,600 seconds, and the job message supplies that token to
the runner without a replacement. The changed helper validates expiry for later job-server requests,
despite workflow configuration supporting a 360-minute job; job completion instead uses the runner
credential, so it can succeed after those requests are rejected.

src/app/services/job_token_service.py[24-36]
src/app/services/job_token_service.py[62-64]
src/app/api/actions_runner_protocol.py[106-107]
src/app/api/actions_distributed_task.py[374-381]
src/app/services/job_token_service.py[20-58]
src/app/api/actions_distributed_task.py[649-667]
src/app/services/workflow_service.py[268-283]
src/app/api/actions_distributed_task.py[1405-1418]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The runner receives one job token that expires after an hour, but job-server routes now enforce that expiry even though supported jobs can run for six hours. Requests for logs, timeline updates, and action downloads can therefore fail while the job continues.

## Fix Focus Areas
- src/app/services/job_token_service.py[20-58]
- src/app/api/actions_distributed_task.py[374-381]
- src/app/api/actions_distributed_task.py[649-667]

## Recommended Fix
Keep signature and issuer validation, but ensure the runner has a valid job credential for the supported job duration. Set `exp` to cover the configured `timeout-minutes` (default 360) plus a margin, with a 24-hour cap if appropriate, or implement bounded renewal. Add a test showing that job-server requests for an in-progress job still accept a token issued just over an hour earlier.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
❌ Tickets: failed to load — Ticket collection could not establish complete evidence
✅ Compliance rules (platform): 6 rules
✅ Cross-repo context — repo relationships
  Explored: repo: fullsend-ai/fullsend (sha: f28397f5) — View relationship
Review mode: Auto: 🧠 Deep: Multiple security-sensitive access paths create several independent defect opportunities.

Grey Divider

Tip of the day
💡 Did you know, you can describe a rule in plain language on the Rules page and Qodo drafts it for you

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread src/app/api/actions_distributed_task.py Resolved
Comment thread src/app/api/actions_distributed_task.py Resolved
@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Nov 18, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Moderate change size with solid test coverage and no protected or dependency files, closely aligned with linked issue scope despite modifying existing authorization behavior without flags.

Previous run

Risk Assessment: moderate (2/5)

Details

Moderate change size with solid test coverage and no protected or dependency files, closely aligned with linked issue scope despite modifying existing authorization behavior without flags.

Previous run (2)

Risk Assessment: moderate (2/5)

Details

Moderate change size across 9 files implementing Actions token, role, and runner scope checks with solid test coverage and no protected paths, dependency changes, or author contention.

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Review

Findings

Medium

  • [api-contract] src/app/api/actions.py:856 — Repository secret PUT (and DELETE at ~885) now require admin via _require_repository_role(..., "admin", job_token=False), so a write/maintain collaborator using their own credentials gets 403. GitHub's REST reference for these endpoints says authenticated users need collaborator access, and the PR is internally inconsistent: it requires write for Actions variables but admin for secrets. The new tests assert the stricter behaviour. The PR body states admin was chosen deliberately and the 403 text matches what GitHub is known to return, so this needs a check against real GitHub before any change.
    Remediation: Confirm GitHub's behaviour for a write-role caller on repository secret PUT/DELETE. If GitHub allows it, use "push" on those routes and update tests/test_actions_write_permissions.py. If GitHub returns 403, document that in the bug entry and close this finding. Keep admin for .../actions/permissions.

Low

  • [backward-incompatible] src/app/services/job_token_service.py:67 — issue_job_token sets exp = now + 3600 and validate_job_token enforces it. The job-server routes (timeline, feed, logs, action download info, archive) now go through it, so a job running over one hour gets 401 Invalid job token on those routes. The same expiry already applied to the REST API and OIDC paths, so this extends an existing limit rather than creating a new one. The PR body does not mention it.
    Remediation: Make the token lifetime match the job timeout (a configurable exp of 6 hours or more, or derived from timeout-minutes). Document the lifetime and add a test for a job running longer than an hour.

  • [auth-bypass] src/app/api/actions_distributed_task.py:274 — Pre-existing and not changed by this PR. dt_oauth_token issues and stores a runner bearer token based only on the caller-supplied runner_id. Knowing another runner's id is enough to get its credential and rotate its token_hash, which undermines the new _same_scope_as pool-agent scoping. The linked tracking issue lists a follow-up for the runner credential on the token exchange routes.
    Remediation: Authenticate the OAuth client against the selected runner's registered credential or public key before rotating its token, and add a regression test. This can be handled in the follow-up issue.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImJhY2t3YXJkLWluY29tcGF0aWJsZSIsImZpbGUiOiJzcmMvYXBwL3NlcnZpY2VzL2pvYl90b2tlbl9zZXJ2aWNlLnB5IiwiaWQiOiJmX2UwZGQzMTk2MDU3NjcyYTQiLCJsaW5lIjo2NywiYWN0aW9uYWJsZSI6dHJ1ZSwiZGltZW5zaW9uIjoiY3Jvc3MtcmVwby1jb250cmFjdHMifSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJhdXRoLWJ5cGFzcyIsImZpbGUiOiJzcmMvYXBwL2FwaS9hY3Rpb25zX2Rpc3RyaWJ1dGVkX3Rhc2sucHkiLCJpZCI6ImZfZmY2MmMxNzZhMzc5OWU0NCIsImxpbmUiOjI3NCwiYWN0aW9uYWJsZSI6ZmFsc2UsImRpbWVuc2lvbiI6InNlY3VyaXR5In1dfQ== -->

Review

Findings

Medium

  • [backward-incompatible] src/app/services/job_token_service.py:67 — The job-server routes (timeline records and feed, plan logs, action download info, action archive) now go through validate_job_token, which enforces the token's exp. issue_job_token sets exp = now + 3600. The token is minted once, when the job message is built, and nothing refreshes it. Before this PR these routes never checked exp. A job that runs longer than about an hour will now get 401 on every timeline update, log upload and feed call. GitHub scopes the job token to the job's lifetime. The new tests only cover an expired token and a fresh one.
    Remediation: Make the token lifetime cover the job (for example derive exp from the job timeout, default 360 minutes plus a margin), or accept an expired token on job-server routes while its job is in_progress. Add a test for a job running past one hour.

Low

  • [auth-bypass] src/app/api/actions_distributed_task.py:274 — Not introduced by this PR. dt_oauth_token (POST /_apis/oauth2/token?runner_id=<id>) issues a fresh credential for any runner id and overwrites its token_hash without checking a client assertion or the runner's existing credential. Anyone holding that credential is treated as the victim runner's scope by the new _same_scope_as filter. That limits what the runner-scope change achieves but does not undo it, because the base had no scoping at all. Issue Check the runner's credential on the token exchange and deregister routes #43 already tracks this. Consider noting the limitation in docs/bugs/fixed/runner-agent-routes-are-not-scoped-to-the-runner.md.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (2)

Review

Reason: tool-failure

This PR was NOT reviewed. Do not count this as an approval.

Previous run (3)

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6InJiYWMtdmlvbGF0aW9uIiwiZmlsZSI6InNyYy9hcHAvYXBpL2FjdGlvbnMucHkiLCJpZCI6ImZfYjE1NmQ3NTJhYjExYWFmYiIsImxpbmUiOjM3MywiYWN0aW9uYWJsZSI6ZmFsc2UsImRpbWVuc2lvbiI6InNlY3VyaXR5In0seyJzZXZlcml0eSI6Im1lZGl1bSIsImNhdGVnb3J5IjoicmJhYy12aW9sYXRpb24iLCJmaWxlIjoic3JjL2FwcC9hcGkvYWN0aW9uc19kaXN0cmlidXRlZF90YXNrLnB5IiwiaWQiOiJmXzIxMWNmMDdjNjRkZGQ1ZjAiLCJsaW5lIjoxMjY4LCJhY3Rpb25hYmxlIjpmYWxzZSwiZGltZW5zaW9uIjoic2VjdXJpdHkifSx7InNldmVyaXR5IjoibWVkaXVtIiwiY2F0ZWdvcnkiOiJhcGktY29udHJhY3QiLCJmaWxlIjoic3JjL2FwcC9hcGkvYWN0aW9ucy5weSIsImlkIjoiZl8wYzYxMDBkMzkwODkyMzYyIiwibGluZSI6OTg0LCJhY3Rpb25hYmxlIjpmYWxzZSwiZGltZW5zaW9uIjoiY29ycmVjdG5lc3MifSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJlZGdlLWNhc2UiLCJmaWxlIjoic3JjL2FwcC9hcGkvYWN0aW9uc19kaXN0cmlidXRlZF90YXNrLnB5IiwiaWQiOiJmXzczYjI4NjA2MDJmYzBjNjEiLCJsaW5lIjozNzcsImFjdGlvbmFibGUiOnRydWUsImRpbWVuc2lvbiI6ImNvcnJlY3RuZXNzIn0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoiYXBpLWNvbnRyYWN0IiwiZmlsZSI6InNyYy9hcHAvYXBpL2FjdGlvbnMucHkiLCJpZCI6ImZfMWRhZTFmMDc0NzVkZDEzNSIsImxpbmUiOjg0OCwiYWN0aW9uYWJsZSI6ZmFsc2UsImRpbWVuc2lvbiI6ImNvcnJlY3RuZXNzIn0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoiYmFja3dhcmQtaW5jb21wYXRpYmxlIiwiZmlsZSI6InNyYy9hcHAvYXBpL2FjdGlvbnMucHkiLCJpZCI6ImZfYjIzYzEwYmRiODRhNjRhMyIsImFjdGlvbmFibGUiOmZhbHNlLCJkaW1lbnNpb24iOiJjcm9zcy1yZXBvLWNvbnRyYWN0cyJ9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImJhY2t3YXJkLWluY29tcGF0aWJsZSIsImZpbGUiOiJzcmMvYXBwL2FwaS9hY3Rpb25zX2Rpc3RyaWJ1dGVkX3Rhc2sucHkiLCJpZCI6ImZfMmYyZjk0ODkzODZiNWI2NyIsImFjdGlvbmFibGUiOmZhbHNlLCJkaW1lbnNpb24iOiJjcm9zcy1yZXBvLWNvbnRyYWN0cyJ9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImJhY2t3YXJkLWluY29tcGF0aWJsZSIsImZpbGUiOiJzcmMvYXBwL2FwaS9hY3Rpb25zX2Rpc3RyaWJ1dGVkX3Rhc2sucHkiLCJpZCI6ImZfMjI2NDc0ZjM1YjQxYThlNCIsImFjdGlvbmFibGUiOmZhbHNlLCJkaW1lbnNpb24iOiJjcm9zcy1yZXBvLWNvbnRyYWN0cyJ9XX0= -->

Review

Findings

Medium

  • [rbac-violation] src/app/api/actions.py:373 — _require_repository_role returns early for any workflow job token, including on the admin-only secrets, variables and Actions-permissions routes. A job with actions: write can still change repository secrets, variables and Actions settings, which a real GITHUB_TOKEN cannot do. Not a regression (no role check existed before), but it leaves the PR's goal open.
    Remediation: Reject workflow job tokens on the secret, variable and Actions-permission write routes; add negative tests with a valid actions: write job token.
  • [rbac-violation] src/app/api/actions_distributed_task.py:1268 — Job-server handlers resolve the job from caller-supplied plan_id/timeline_id first and never compare it with the job in the validated token, so a validly signed token for job A can write logs/timeline records for job B. Pre-existing (the base has the same or auth_job fallbacks), but the new signature validation does not close it.
    Remediation: Require the resolved job to match the token's job (or run) and reject mismatches; add two-job negative tests for feed, timeline-record and log routes.
  • [api-contract] src/app/api/actions.py:984 — Repository variable create/update/delete require admin; GitHub's REST docs for variables list write access, so push collaborators get 403 where GitHub would accept them. The PR body acknowledges this, and the new test asserts writers get 403.
    Remediation: Accept the push role for the variable routes and test writer success, or record the deliberate divergence in the bug doc.

Low

  • [edge-case] src/app/api/actions_distributed_task.py:377 — validate_job_token raises an uncaught AttributeError when the header or payload decodes to a non-object, e.g. token W10.e30.x. The job-server and archive routes then return a 500 instead of the 401 Invalid job token the PR promises. Tests do not cover a non-object header/payload.
    Remediation: Return None from validate_job_token when the decoded header/payload is not a dict (or catch AttributeError), and add malformed-header/payload cases asserting 401.
  • [api-contract] src/app/api/actions.py:848 — Repository secret create/update and delete now require admin. GitHub's REST reference says "collaborator access" while its secrets guide says owner/admin, so the divergence is uncertain.
    Remediation: Optional: check real GitHub behaviour for a push collaborator and relax to the push role if writers succeed.
  • [backward-incompatible] src/app/api/actions.py — Actions write routes now return 403 for read-only or no-role callers, and cancel returns 404 for another repository's run. Fixtures using a read-only or non-owner PAT will break.
    Remediation: Note this for downstream consumers (tests, fullsend).
  • [backward-incompatible] src/app/api/actions_distributed_task.py — Pool agent list, update and delete are now scoped to the caller runner's repo/org/enterprise; cross-scope access returns an empty list or 404. Intended, but breaks setups that replaced or removed runners across scopes.
  • [backward-incompatible] src/app/api/actions_distributed_task.py — Job-server routes and the action archive now validate job-token signature, issuer and expiry. Hand-crafted, unsigned, other-issuer and expired tokens get 401, and the old Job token target not found response is now Invalid job token.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ❌ Failure (post-script /home/runner/work/github-emulator/github-emulator/.fullsend/.fullsend-cache/resources/sha256/e7a9998a1b648e11a40a2f74e5b270e63707430a0953227f2f651b4c86d70654/scripts/post-review.sh failed:…) · Started 11:16 PM UTC · Completed 11:37 PM UTC

Commit: 724efda · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.37

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 3:09 AM UTC · Completed 3:20 AM UTC

Commit: 724efda · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.79

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Nov 19, 2026
fullsend-ai-review[bot]

This comment was marked as outdated.

fullsend-ai-review[bot]

This comment was marked as outdated.

@jctanner jctanner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving with nits. This is the security keystone for the batch: signature/issuer/lifetime verification on every job-server route, plan/timeline binding to the token's own job, runner-scope filtering on the pool agent routes, and role checks on the Actions write routes — all verified with negative tests. One medium known issue, already fixed by #34: the job token's 1 h expiry with no refresh would 401 long-running jobs on the job-server routes — keep the #31 → #34 merge order. Nits: note the dt_oauth_token limitation in the scoping bug note (fixed by #44), and the low findings the bot reclassified as intentional are fine.

The job-server routes the upstream runner calls (timeline records and
feed, logs, action download info and the action archive) now
authenticate the job token through the existing validate_job_token,
which checks its signature, issuer and lifetime, and answer 401 when it
fails. GitHub accepts only a job token it issued; the runner's own token
works as before.

Tests: tests/actions/test_job_token_routes.py (a bad signature, an
unsigned token, another issuer and an expired token on every route).

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
Dispatch, cancel, re-run and artifact upload or delete now require write
access to the repository. Actions secrets, variables and permissions
require admin access (the owner, for a personal repository). A site
admin passes. A job's GITHUB_TOKEN and an App installation token keep
the per-route permission checks they already get at authentication.

Cancel acts only on a run of the repository in its path; another run id
is 404, as for re-run.

Tests: tests/test_actions_write_permissions.py (cancel by a user with no
role, a reader and a writer; a run of another repository; re-run by a
reader; secrets, variables and permissions by each role).

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
Listing, updating and removing pool agents covered every runner on the
instance. On GitHub a runner belongs to the repository, organization or
enterprise it registered with, and its credential sees only the agents
there. The three routes now match on that scope; a runner outside it is
not listed, and updating or removing it is 404.

Tests: tests/actions/test_runner_agent_scope.py.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
The runner addresses each job-server call with the plan (the run) and
timeline (the job) ids from its job message. The feed, timeline records,
log and action download info routes now check that the plan and
timeline in the path are the job token's own, answer 404 otherwise, and
write only to the token's job. They no longer look a job up by plan or
timeline id, so two jobs of one run also keep their logs apart.

validate_job_token now refuses a token whose header or payload is not a
JSON object (401), instead of failing with a server error.

Tests: tests/actions/test_job_token_route_targets.py (another run's plan,
another job's timeline in the same run); two more token shapes in
tests/actions/test_job_token_routes.py.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
…s or settings

GitHub's REST reference for repository variables asks for write access,
so variable create, update and delete now take the write role instead of
admin. Secrets and Actions permissions keep admin.

A job's GITHUB_TOKEN has no permission for secrets, variables or
repository administration, so GitHub answers it with 403 "Resource not
accessible by integration" on those routes. The emulator now does the
same; a job token's actions permission still covers dispatch, cancel,
re-run and artifacts.

Tests: tests/test_actions_write_permissions.py (a writer manages
variables, a reader and a user with no role cannot; a job token with
actions: write gets 403 on secrets, variables and permissions and can
still cancel a run).

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 5:22 PM UTC · Completed 5:31 PM UTC

Commit: f3b349f · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.77

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note: The following review comments could not be posted on the diff (GitHub returned 422) and are included here instead:

  • src/app/services/job_token_service.py (file-level): Line 67 ·
    [low] backward-incompatible

issue_job_token sets exp = now + 3600 and validate_job_token enforces it. The job-server routes now go through it, so a job running over one hour gets 401 Invalid job token on them. The same expiry already applied to the REST API and OIDC paths.

Suggested fix: Make the token lifetime match the job timeout (configurable exp of 6 hours or more, or derived from timeout-minutes), document it, and add a test for a job running longer than an hour.

  • src/app/api/actions_distributed_task.py (file-level): Line 274 ·
    [low] auth-bypass

Pre-existing: dt_oauth_token issues and stores a runner bearer token based only on the caller-supplied runner_id, which undermines the new _same_scope_as pool-agent scoping. Not changed by this PR.

Suggested fix: Authenticate the OAuth client against the selected runner credential or public key before rotating its token, and add a regression test; may be handled in the follow-up issue.

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See the review comment for full details.

Comment thread src/app/api/actions.py Resolved
@waynesun09
waynesun09 merged commit 3f31565 into main Nov 19, 2026
38 checks passed
@waynesun09
waynesun09 deleted the emu-14-access-checks branch November 19, 2026 17:33
waynesun09 added a commit that referenced this pull request Nov 19, 2026
Rebased onto #31, every other job-server route answers 404 for a plan that is not the job's own run; the plan events route now does too. validate_job_token comes from the module-level import #31 added. #31's route-target test counts the per-step log files this change writes, since uploads no longer append to the console log.

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
jctanner added a commit that referenced this pull request Nov 20, 2026
…scope with runner scoping

- migrations 0018_runner_public_key/0019_runner_registration_broker renumbered
  to 0020/0021 (0018 and 0019 are taken by merged #41 and #24)
- dt_update_pool_agent: ordinary runners keep #31's scope-filtered lookup
  (out-of-scope is 404); registration brokers look up unscoped and get #44's
  403 broker-scope refusal, as both PRs' tests pin
- full suite: 1494 passed, 1 known sandbox failure (test_security_headers
  needs a built frontend/dist)
jctanner added a commit that referenced this pull request Nov 20, 2026
…egister

Merges current main into the branch, renumbers the migrations to
0020_runner_public_key and 0021_runner_registration_broker (0018 and 0019
are taken by merged #41 and #24), and reconciles the pool-agent update
authorization: ordinary runners keep #31's scope-filtered lookup
(out-of-scope is 404) while registration brokers look up unscoped and get
the 403 broker-scope refusal, as both PRs' tests pin.

Full suite: 1494 passed, 1 known sandbox failure (test_security_headers
needs a built frontend/dist).

Signed-off-by: James Tanner <jtanner+github@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants