fix(browser-transfer): release the vault slot of a capability put() or open() did not consume (01-07)
Only consume() removed a vault entry, so a refused, expired or aborted transfer held a maxActiveCapabilities slot until expiry and later issuance failed as LIMIT_EXCEEDED. The executor now revokes on every exit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c0b7ff1576
commit
b52ca8d69b
@@ -105,6 +105,10 @@ export function createPresignedTransferExecutor(
|
||||
): PresignedTransferExecutor {
|
||||
const resolve = options.vault.resolve.bind(options.vault);
|
||||
const consume = options.vault.consume.bind(options.vault);
|
||||
// 01-07. A resolved identity that is never consumed is retired on the way
|
||||
// out, so a refused, expired or aborted transfer does not hold a vault slot
|
||||
// until its expiry. Idempotent after consume().
|
||||
const revoke = options.vault.revoke.bind(options.vault);
|
||||
const claim = options.replayGuard.claim.bind(options.replayGuard);
|
||||
const hardMaxTransferBytes = positiveSafeInteger(
|
||||
options.hardMaxTransferBytes,
|
||||
@@ -184,6 +188,7 @@ export function createPresignedTransferExecutor(
|
||||
capability.binding.resourceId !== resourceId ||
|
||||
!validCommonBinding(binding, capability, hardMaxTransferBytes)
|
||||
) {
|
||||
revoke(capability);
|
||||
return browserDataFailure("POLICY_REJECTED", "PRESIGNED_TRANSFER");
|
||||
}
|
||||
const active = validateExpiry(
|
||||
@@ -191,9 +196,11 @@ export function createPresignedTransferExecutor(
|
||||
minimumRemainingLifetimeMs,
|
||||
now(),
|
||||
);
|
||||
if (!active.ok) return active;
|
||||
const claimed = claim(capability);
|
||||
if (!claimed.ok) return claimed;
|
||||
const claimed = active.ok ? claim(capability) : active;
|
||||
if (!claimed.ok) {
|
||||
revoke(capability);
|
||||
return claimed;
|
||||
}
|
||||
const consumed = consume(capability);
|
||||
if (!consumed.ok) return consumed;
|
||||
|
||||
@@ -319,6 +326,7 @@ export function createPresignedTransferExecutor(
|
||||
capability.expectedSha256 !== request.checksumSha256 ||
|
||||
bytes.byteLength !== capability.byteLength
|
||||
) {
|
||||
revoke(capability);
|
||||
return browserDataFailure("POLICY_REJECTED", "PRESIGNED_TRANSFER");
|
||||
}
|
||||
// TR-RR-02. The abort scope is created first, so the digest — which can be
|
||||
@@ -414,6 +422,7 @@ export function createPresignedTransferExecutor(
|
||||
return transferFailure(request.signal, scope.timedOut());
|
||||
} finally {
|
||||
scope.release();
|
||||
revoke(capability);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user