Skip to content

fix(station): re-check the requester after preparing a request - #676

Merged
sea-snake merged 4 commits into
mainfrom
fix/recheck-requester-on-request-creation
Nov 3, 2026
Merged

sea-snake merged 4 commits into
mainfrom
fix/recheck-requester-on-request-creation

Conversation

@sea-snake

Copy link
Copy Markdown
Contributor

Summary

RequestService::create_request now re-checks the requester after the request has been prepared and before it is stored. Preparing a request can await an external call (the validation method of a CallExternalCanister request), and the caller was only authorized once, before that await. The service now reloads the caller's user and runs the same authorization the create_request endpoint runs, for the same resource. If the caller no longer maps to the same user, the user is no longer active, or the permission no longer allows the request, creation fails with RequestError::Unauthorized and nothing is stored.

Changes

  • services/request.rs: compute the request's Resource before the input moves into the factory, and after the factory returns, refuse creation unless the caller still resolves to the requester and Authorization::is_allowed passes.
  • Unit tests that call create_request directly now grant the permission their request needs, because the service checks it as well as the endpoint.

Tests

  • New create_request_refuses_requester_deactivated_after_authorization: an active requester creates a request, then the same call context (authorized while the user was active) is refused with UNAUTHORIZED after the user is set inactive, and no second request is stored. The test fails without the change.
  • cargo test -p station --lib: 410 passed, 0 failed.
  • cargo fmt --check and cargo clippy -p station --tests -- -D warnings are clean.

🤖 Generated with Claude Code

Preparing a request can await an external validation call, so the
requester's status and permission are checked again before the request
is stored.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sea-snake
sea-snake requested a review from a team as a code owner October 23, 2026 12:42
Copilot AI balanced review requested due to automatic review settings October 23, 2026 12:42
@zeropath-ai

zeropath-ai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to b28aa7c.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► core/station/impl/src/models/request_policy.rs
    Add permission handling imports and repository interaction in tests
► core/station/impl/src/services/request.rs
    Enforce authorization against current requester state and resource permissions
Enhancement ► tests/canister/integration/src/external_canister_tests.rs
    Add external canister request test for deactivated requester during validation

Copilot AI 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.

🟡 Changes recommended

Public permissions still allow inactive requesters through the guard, and the regression test does not cover deactivation during suspended preparation.

2 open issues
What changed in this PR

This PR strengthens station request creation by reloading the requester and checking authorization after potentially asynchronous preparation, before storing the request.

Changes:

  • Capture the request resource and recheck requester identity and authorization after preparation.
  • Grant required permissions in existing test fixtures.
  • Add a regression test for request creation using a previously authorized, now-inactive requester.
File Description
core/​station/​impl/​src/​services/​request.rs Add post-preparation authorization checks and update request tests.
core/​station/​impl/​src/​models/​request_policy.rs Grant user-creation permission in the request-policy test helper.

Review effort: Balanced

sea-snake and others added 2 commits October 23, 2026 14:56
…ending

Adds an integration test that keeps a call external canister request's
validation call pending, deactivates the requester meanwhile, and checks
that the request is refused once validation replies.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The re-check after preparing a request now requires the requester to be
active independently of the resource permission, so a public permission
does not let a deactivated requester's request through.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… of https://github.com/dfinity/orbit into fix/recheck-requester-on-request-creation

# Conflicts:
#	tests/canister/impl/src/lib.rs
#	tests/integration/src/external_canister_tests.rs
@sea-snake
sea-snake enabled auto-merge (squash) November 3, 2026 12:25
@sea-snake
sea-snake merged commit be20ba8 into main Nov 3, 2026
29 checks passed
@sea-snake
sea-snake deleted the fix/recheck-requester-on-request-creation branch November 3, 2026 12:50
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