Repository navigation
Conversation
…before any lock; check the signature before policy admission
… stranger-lease pre-check; preverify uncovered bytes in delegate_verified
This branch has not been deployed
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.
/delegateand/revoke: refuse requests without standing before taking any lock (TC-3000)Follow-up to #595 (TC-2986 E). That PR moved the signature check ahead of every lock. A validly signed request with no authority could still take the victim's locks before it was refused: anyone can sign with a fresh
did:key. Such a request is:Before being refused, it took the guards of the delegation chain it cited and queued for the write order of the spaces it named. On PostgreSQL it also held a pooled connection in an open transaction while waiting for the space advisory lock.
F1: a pre-check on the pool, before any lock
After the signature, and before the chain guards, the spaces' write order or a transaction,
/delegateand/revokerun the checks that need no lock. They run on the pool and are read-only.delegation::precheck):key.delete);owner_controls_target) for the rest, or every cited parent is stored and was granted to the issuer. The parents are read in one query by exact id, the same lookup the transaction's graph snapshot uses. Policy roots and policy-session shapes are treated exactly as invalidate_with.revocation::precheck): the samecheck_standingthe transaction runs. That is the time window, a stored target, andrevoker_is_authorized.process_withnow calls the same function, so the two cannot drift.save_owner_renewal_lease(time window, no parents, an original to renew).preverify_lease_original, which already reads the stored original before the locks, also refuses a lease not issued by the original's delegator.Every check runs again inside the transaction, which stays the authority. The pre-check refuses only what the transaction would refuse. The checks are the same functions, run in the same order. The one difference is that a cited parent is read directly instead of through the graph snapshot.
Unchanged behaviour:
Accepted edges:
Cannot find parent delegation. Clients that pipeline a parent and its child without waiting for the parent's response must retry. The CHANGELOG says so.Cannot find parent delegationrather than the traversal-limit error.F6:
/delegatechecks the signature before the Policy/v3 admissionThe route now calls
preverify_delegationbeforeordinary_admission_allowed. That admission does one primary-key read per cited parent, and for policy-session shapes a walk of up to 9 hops. The route then registers through the newSpaceDatabase::delegate_verified, so the signature is checked once. When thePreVerifiedit is given does not cover the delegation's bytes,delegate_verifiedchecks the signature itself before any read or lock (review N5).delegate()isdelegate_verifiedwith an empty set.Visible change: a badly signed delegation citing a policy root answers 401
Failed to verify signatureinstead of 403.F5: a test pins the stored-original hash check
a_stored_original_whose_bytes_do_not_match_its_address_is_refusedcoversstored_original, which bothpreverify_lease_originaland the in-transaction lease check use. It fails if the hash comparison is removed.Tests
New tests only; no existing test changed.
db/signature_before_locks_tests.rs, Bobbie's fix: check /delegate and /revoke signatures before any lock (TC-2986 E) #595 residual probes inverted. Each asserts the refusal arrives within 5 s while the victim's lock is held:MissingParentswhile the space write order is held;UnauthorizedRevoker;InvalidTime;UnauthorizedDelegator, while that grant's chain guard is held) and a child citing a missing parent (MissingParents);delegations_with_standing_still_wait_for_their_locks_and_are_admitted;a_stored_delegation_posted_again_after_it_expired_is_still_registered.delegate_checks_the_signature_before_policy_admission, on both backends.a_revocation_whose_control_grant_is_revoked_while_it_waits_is_refused(her R4) re-pins the in-transaction revoker check (N2). The revocation passes the pre-check through a revoke control grant and waits on its target's chain guard. The grant is revoked meanwhile, and the transaction refusesUnauthorized Revoker.a_stranger_renewal_lease_is_refused_before_its_locks(her R2): the lease is refused while its own chain guard and the SQLite writer lock are held (N3).an_expired_delegation_is_refused_without_a_pre_check:delegate_batch, which has no pre-check, still refuses an expired delegation inside the transaction. This pinsverify_timeinprocess_with.Mutation checks:
verify_timeremoved, or the lease delegator check inpreverify_lease_originalremoved, exactly the three review tests fail.Follow-up, not in this PR: TC-3086 (review N1). The pre-check accepts any stored parent granted to the issuer; it should also require that parent's abilities to cover each capability, ignoring caveats and time.
Details: TC-3000.