Skip to content

fix(api): validate resolved trigger identity (1.8 backport) - #1627

Merged
scttbnsn merged 2 commits into
dev/v1.8from
fix/v1.8-trigger-scope
Nov 18, 2026
Merged

scttbnsn merged 2 commits into
dev/v1.8from
fix/v1.8-trigger-scope

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Backport of the 1.9 fix for 1.8.0-rc.16 (pre-existing issue, also in 1.7).

An API key scoped to triggers:test could run an agent's action trigger by putting the agent name in the type segment (/triggers/edge1.docker/update), skipping update admission. The route now checks that the resolved trigger's type, name and agent match the path, and scope and dispatch use the resolved trigger's real type. Also brings the container-actions flag to the trigger run routes and fixes the case-sensitive webhook endpoint-secret check.

Changelog

🔒 Security

  • Fixed: API key scoped to triggers:test could run an agent action trigger. The route built a trigger key that resolved to an agent-owned component, and the early scope check filed it as notification.
  • runTrigger (local) and runRemoteTrigger now verify that the resolved component's type, name, and agent match the route. Mismatches return 404.
  • Scope is now derived from the resolved component's type, not the route's type.

🐛 Fixed

  • app/api/webhook.ts: getWebhookActionFromRequest lowercases the normalized path before route matching. Path matching is now case-insensitive.
  • runTrigger and runRemoteTrigger do not dispatch update actions based on the route type. They use triggerToRun.type.

✨ Added

  • app/api/trigger-identity.ts: doesTriggerMatchRoute(component, route). Returns true when type and name are equal and (component.agent ?? '') equals route.agent.
  • Container-actions gate on trigger run routes:
    • app/api/trigger.ts runTrigger: returns 403 for action triggers when areContainerActionsEnabled() is false.
    • app/api/trigger.ts runRemoteTrigger: returns 403 for action triggers before agent lookup. The check uses the route triggerType.
    • app/api/container/triggers.ts runTrigger: returns 403 for action triggers when actions are disabled. Required scope is containers:update for actions and triggers:test otherwise.
  • Tests:
    • app/api/trigger-routes-alias.test.ts (new, 71 lines): aliased notification-trigger routes return 404. No proxy, update, or agent lookup runs.
    • app/api/container/triggers.test.ts (+171): agent-qualified route rejection, mismatched agent refusal, disabled-action 403 for Docker and command triggers, notification triggers still run.
    • app/api/trigger.test.ts (+256/-1): alias handling, canonical explicit-agent update, disabled-action 403 before agent lookup, scope recheck after resolution.
    • app/api/webhook-auth.integration.test.ts (new, 164 lines): per-endpoint token selection across mixed-case paths and trailing slashes. Disabled webhooks return 403.
    • app/api/container.test.ts (+19/-?): runTrigger mock fixtures include type, name, and agent.

🔧 Changed

  • app/api/container/triggers.ts: imports areContainerActionsEnabled, CONTAINER_ACTIONS_DISABLED_MESSAGE, and doesTriggerMatchRoute.
  • app/api/trigger.ts: imports the same helpers plus doesTriggerMatchRoute.
  • Diff size: 10 files, +771/-10.

Concerns

  • runRemoteTrigger (app/api/trigger.ts) checks the disabled-actions gate using the route triggerType, not the resolved component type. Confirm the scope check in that handler also keys off the resolved type. This was not visible in the diff hunks reviewed.
  • Two scope-selection paths exist: requiredScopeForTriggerType(...) in trigger.ts and an inline ternary in container/triggers.ts. Consolidate into one helper.
  • Two action-category checks exist: getTriggerCategoryForType is called in both files. Consider a shared guard.
  • doesTriggerMatchRoute is used in three call sites with the same shape. Consider one wrapper that builds the route object.
  • The webhook.ts change lowercases only the request path used for action routing. Verify the endpoint-secret comparison in the same module also uses the normalized path. The diff does not show that code.
  • runRemoteTrigger route validation: the explicit-agent test asserts the update request runs once. Confirm no direct proxy path remains reachable with a mismatched agent.
  • Test line counts in the raw summary differ slightly from the diff stat (for example, trigger.test.ts 255 vs 256). Use the diff stat values.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Trigger handlers now validate resolved trigger identity, check action availability and API-key scope, and use the resolved trigger type for update dispatch. Webhook action matching now lowercases normalized request paths. Tests cover trigger identity, action controls, and webhook credential selection across path variants.

Change: Bug fix

Merge Risk: Minimal · up to b015e

The change validates that a resolved trigger matches the request path and applies action gating and scope checks to the resolved trigger. It also makes the webhook endpoint-secret path matching case-insensitive. No concrete merge-blocking risk remains in the reviewed changes.

Pre-merge checks: Passed 2

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7037be0 and b015eef.

Files ignored due to path filters: 1

  • CHANGELOG.md is excluded by !CHANGELOG.md
Files selected for processing: 9

  • app/api/container.test.ts
  • app/api/container/triggers.test.ts
  • app/api/container/triggers.ts
  • app/api/trigger-identity.ts
  • app/api/trigger-routes-alias.test.ts
  • app/api/trigger.test.ts
  • app/api/trigger.ts
  • app/api/webhook-auth.integration.test.ts
  • app/api/webhook.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttbnsn
scttbnsn merged commit 46c85e3 into dev/v1.8 Nov 18, 2026
33 checks passed
@scttbnsn
scttbnsn deleted the fix/v1.8-trigger-scope branch November 18, 2026 23:12
scttbnsn added a commit that referenced this pull request Nov 19, 2026
* docs(release): open the v1.8.0-rc.16 changelog entry

* docs(release): prepare v1.8.0-rc.16 candidate metadata

Prepare opt-in RC16 metadata, current docs, translated READMEs, demo fixtures and release identity checks.

Includes:
- #1627 trigger alias scope bypass (security)
- #1628 scan the running digest (security)
- #1639 openssl 3.5.9-r1 pin with a scoped fixed OpenVEX
- #1641 static site render
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.

1 participant