Repository navigation
Conversation
A block-level "trusting <key>" scope holds an index into that block's
own public-key list. For a third-party block that list is independent
of the token's. Authorizer passed the raw indices to
TrustedOrigins.fromScopes along with publicKeyToBlockId, which is keyed
by indices into the authorizer's table, so the scope could resolve to a
different key than the one the block names. A key the token holder had
introduced could end up trusted in place of the intended one, and the
intended key was no longer trusted.
Translate block scopes into the authorizer's index space before
computing trusted origins, in both updateOnToken and authorize, using
Scope.convertFrom with the block's own table followed by Scope.convert
into the authorizer's table. This is how rule-level and check-level
scopes are already handled.
convertFrom narrows the 64-bit key index to an int and assumes the key
exists, so validate the index against the block's public-key list first.
A scope naming a key the block does not declare now fails with the new
LogicError.InvalidBlockScope instead of wrapping around to another key
or throwing an unchecked exception.
Add two tests to ThirdPartyTest that build a token where index 0 differs
between the two tables:
- testThirdPartyBlockLevelScopeRejectsFactFromUntrustedKey: mfa(true)
is signed by an unrelated key, so the check must fail.
- testThirdPartyBlockLevelScopeAcceptsFactFromTrustedKey: mfa(true)
is signed by the partner key named in the scope, so the check must
pass.
Co-authored-by: Doug Schneider <dschneider@apple.com>
Signed-off-by: Saoirse Aronson <saoirse@apple.com>
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.
A block-level "trusting " scope holds an index into that block's own public-key list. For a third-party block that list is independent of the token's. Authorizer passed the raw indices to TrustedOrigins.fromScopes along with publicKeyToBlockId, which is keyed by indices into the authorizer's table, so the scope could resolve to a different key than the one the block names. A key the token holder had introduced could end up trusted in place of the intended one, and the intended key was no longer trusted.
Translate block scopes into the authorizer's index space before computing trusted origins, in both updateOnToken and authorize, using Scope.convertFrom with the block's own table followed by Scope.convert into the authorizer's table. This is how rule-level and check-level scopes are already handled.
convertFrom narrows the 64-bit key index to an int and assumes the key exists, so validate the index against the block's public-key list first. A scope naming a key the block does not declare now fails with the new LogicError.InvalidBlockScope instead of wrapping around to another key or throwing an unchecked exception.
Add two tests to ThirdPartyTest that build a token where index 0 differs between the two tables: