Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refactor(host_api): centralize system-sentinel id minting and pin authority contract #4584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
refactor(host_api): centralize system-sentinel id minting and pin authority contract #4584
Changes from all commits
0f0ea86a62d52fa18491cadb5b491a7558db7700525701d66File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 Medium — Security — #2:
system_sentinel()ispub— any crate can mint system-authority IDs without auditsystem_sentinel()ispubon pub typesTenantId/UserId. Every downstream crate — product adapters, integration glue, WASM shims — can call it to produce an ID that passesResourceScope::is_system().from_trusted()was already pub but anonymous;system_sentinel()is semantically named, prominently doc-commented as the "blessed path", and therefore far more discoverable. A developer writing a new service could call it to produce a "system" scope for what they believe is a privileged operation, bypassing per-tenant isolation without any capability check or audit event. Documentation-as-security is not an access-control mechanism.Fix: Restrict to
pub(crate), or if cross-crate use is genuinely needed, gate on a zero-sized capability token so the type system enforces the restriction:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ Low — Tests — #8: Stale comment contradicts new
system_sentinel()APIThis comment says "only
from_trustedmay produce it" but the PR addssystem_sentinel()as the blessed cross-crate constructor (and the adjacentsystem_sentinel_constructor_produces_the_reserved_valuetest pins exactly this). The comment now contradicts the new API contract.Fix:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium — Tests — #5:
GovernorBackedAccountantno-actor branch never exercisedresource_scope()uses.unwrap_or_else(UserId::system_sentinel)whenLoopRunContext::actorisNone. Every test helper always sets an actor. No test verifies thatpre_model_callwithactor=Noneroutes reservation to the sentinel user account rather than panicking or using a wrong scope.Fix:
tests::pre_model_call_uses_sentinel_user_when_actor_is_absentcoveringLoopRunContextwithout actorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 High — Tests — #4:
ThreadScope::to_resource_scope()sentinel fallback (owner_user_id=None) never testedThreadScope::to_resource_scope()usesUserId::system_sentinel()whenowner_user_idisNone. All test helpers setowner_user_id: Some(...)— no test constructs aThreadScopewithowner_user_id: Noneand asserts the resultingResourceScopehasuser_id == SYSTEM_RESERVED_IDandis_system() == false. Infrastructure/ownerless threads silently land in the sentinel user slot without coverage.Fix:
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.