-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Store metadata when revoking a permission #228
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?
Conversation
… feat/store-metadata-when-revoking-permission
jeffsmale90
left a comment
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.
A couple of general comments, and, I think a more architectural concern:
I think we should remove isRevoked from the stored permission, and use the existence of revocationMetadata to determine whether the permission is revoked to help improve data integrity.
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
… make txHash property optional on RevocationMetadata type
…ationMetadata to handle legacy data that was created before revocationMetadata was introduced
…egation disable and transaction receipt functions checks to BlockchainMetadataClient class
| .object({ | ||
| txHash: zHexStr.optional(), | ||
| }) | ||
| .default({}), |
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.
As per my previous comment - I think we should remove isRevoked and make the revocationMetadata optional - and remove it's default value.
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.
One other thought - we should ensure that a permission without revocationMetadata, but with isRevoked: true is parsed appropriately with a revocationMetadata (a legacy revoked permission)
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.
We can make revocationMetadata optional, but per the previous comment that you already acknowledged, we cannot remove isRevoked due to an edge case. Let us not continue revisiting the discussion about removing isRevoked, as it has been resolved.
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.
Updated revocationMetadata to optional on the StoredGrantedPermission type
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
| _: Hex, | ||
| __: boolean, | ||
| ___: RevocationMetadata, |
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.
nit: can we use _ prefixed named properties here? I know this is an unconfigured instance, but it would be nice to see from this signature what the properties are
| isRevoked: boolean, | ||
| revocationMetadata: RevocationMetadata, |
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.
as per other comments - we should drop isRevoked, and just make revocationMetadata optional - actually, is there ever a scenario where we want to unrevoke the stored permission?
Maybe this should just be a function markPermissionRevoked that requires the revocationMetadata
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.
We are making revocationMetadata required on the interface on the corresponding GatorPermissionsController PR, so that it seems odd to make the update function take an optional revocationMetadata.
The DelegationManager contract allows enabling delegation after it is disabled, so the permission can be unrevoked.
…etadata optional. Infer TransactionReceipt type from zTransactionReceipt
| permissionContext: zHexStr, | ||
| revocationMetadata: z.object({ | ||
| txHash: zHexStr.optional(), | ||
| }), |
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.
Optional txHash allows skipping transaction verification
Medium Severity
The txHash field in zRevocationParams is marked as optional, which means callers can submit revocations with revocationMetadata: {} (empty object). When txHash is missing, the transaction receipt verification in submitRevocation is entirely skipped due to the if (txHash) guard. While the on-chain delegation disabled check still runs, this bypasses verification that the specific revocation transaction was successful. Based on reviewer feedback indicating "metadata should be required," this appears to be an unintended security gap in the revocation verification flow.
Additional Locations (1)
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.
This bypassing verification is expected behavior, as some submit revocations do not have an associated txHash when the RPC method is called from the MM client. In this edge case, revocations are submitted as revocationMetadata: {} (empty object).
This is highlighted in previous comments: #228 (comment)
Description
Currently, during permission revocation submission, we store a
booleanrevoked flag to track the permission revocation status in profile sync. This PR extends the permission revocation submission process to allow storing additional metadata on the revocation transaction.References
Required by(Core): Attach metadata when submitting a revocation to the permission provider snap
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Introduces on-chain validation and metadata storage for revocations.
BlockchainClient: AddscheckDelegationDisabledOnChainandcheckTransactionReceiptwith retry logic andensureChainusageBlockchainTokenMetadataClientintoBlockchainClientStoredGrantedPermissionwith optionalrevocationMetadata(currentlytxHash); updatesupdatePermissionRevocationStatus(permissionContext, isRevoked, revocationMetadata)to persist/clear metadatasubmitRevocation: ValidatesrevocationMetadata, ensures delegation is disabled on-chain, optionally verifiestxHashsuccess via receipt, then updates profile sync; handler now depends onblockchainClientzTransactionReceiptandvalidateTransactionReceipt; updates revocation params schema; exposesTransactionReceipttypegetTransactionReceiptwith retries inutils/blockchain.tsBlockchainClientinindex.ts; adds/updates comprehensive tests for client, RPC, and profile syncWritten by Cursor Bugbot for commit 5dbb6e6. This will update automatically on new commits. Configure here.