Open
Conversation
Introduce DeviceFilter enum with four variants: - Admin: unrestricted (first/recovery device) - Pallets: whitelist by pallet index - Calls: whitelist by (pallet_index, call_index) pairs - Spend: asset transfer limits with per-asset max amounts Key changes: - New DeviceFilters storage map alongside Devices - register() assigns Admin filter to first device - add_device() takes caller_device + filter params with no-escalation check - PassAuthenticate extension checks filter against call before dispatch - SpendMatcher trait for runtime to provide asset transfer extraction - DeviceFilter::is_superset_of() enforces privilege hierarchy WIP: tests need updating for new add_device signature
All 34 existing tests pass with the new caller_device and filter parameters. Existing tests use DeviceFilter::Admin to maintain current behavior.
Tests for the no-escalation invariant and filter hierarchy: - First device gets Admin filter on registration - Admin can add device with any filter - Restricted (Calls) device cannot escalate to Admin - Spend device cannot escalate to Calls/Pallets - Pallets filter is superset of Calls within those pallets - Spend limit hierarchy (lower ok, higher rejected, wrong asset rejected) - Filter is cleaned up on device removal
- add_session_key now takes a mandatory DeviceFilter parameter - Admin filter rejected for session keys (PermissionEscalation error) - Session key filter stored in SessionKeys storage and checked in PassAuthenticate extension before dispatching - Filter stored as third element in SessionKeys tuple: (account, expiry, filter) New tests: - Session key cannot have Admin filter - Session key stores and retrieves filter correctly
Critical fixes: - Remove self-asserted caller_device param from add_device. The authenticated device_id is now cryptographically bound via AuthenticatedDevice transient storage, set by PassAuthenticate extension during prepare and cleared in post_dispatch. - Remove Default impl for DeviceFilter (was Admin). Missing filter now returns error (deny by default) instead of granting full access. Medium fixes: - add_session_key now enforces no-escalation: the caller's device filter must be a superset of the session's filter. - Extract call_indices() helper to deduplicate call index extraction. The no-escalation check reads AuthenticatedDevice storage, which is only set when authenticating through the PassAuthenticate extension. Direct extrinsic calls in tests must set it explicitly.
Update all benchmark functions for the new add_device and add_session_key signatures. Set AuthenticatedDevice transient storage before calls that require no-escalation checks. Use non-Admin filter for session key benchmarks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a compact per-device call filter system to pallet-pass, enforcing least-privilege access control for authentication devices.
DeviceFilterenum with four variants:Admin— unrestricted (first/recovery device only)Pallets— whitelist by pallet indexCalls— whitelist by (pallet_index, call_index) pairsSpend— asset transfer limits with per-asset max amountsis_superset_of()check inadd_device)PassAuthenticateextension: checks device filter against the dispatched call before setting the originSpendMatchertrait: runtime-provided extraction of(asset_id, amount)from calls forSpendfilter evaluationregister()getsAdmin; subsequent devices require explicit filterStill TODO (will iterate)
Adminallowed, filter check in session key pathTest plan
Addresses virto-network/kreivo#479 (partial)