-
Notifications
You must be signed in to change notification settings - Fork 2k
Use jsonrpc2.Request digest method #19845
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
Merged
DeividasK
merged 10 commits into
develop
from
PRIV-217-audit-cl-79-08-request-digest-collisions
Oct 14, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b13ba34
Use jsonrpc2.Request digest method
DeividasK ccbc78d
Fix for generate
DeividasK 117a375
Add changeset
DeividasK 713a415
Merge remote-tracking branch 'origin/develop' into PRIV-217-audit-cl-…
DeividasK 8e97891
Merge remote-tracking branch 'origin/develop' into PRIV-217-audit-cl-…
DeividasK 54a3d15
Bump chainlink-common
DeividasK 7c61b19
Update the tests
DeividasK 49e53b2
Ensure multiple requests can be allowlisted at the same time
DeividasK 1fa84e2
Restore ToCanonicalJSON
DeividasK 5fe3f44
Go mods tidy
DeividasK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "chainlink": patch | ||
| --- | ||
|
|
||
| #internal changed vault request digest to use jsonrpc2 Digest method |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package vault | |
|
|
||
| import ( | ||
| "context" | ||
| "encoding/hex" | ||
| "encoding/json" | ||
| "testing" | ||
| "time" | ||
|
|
@@ -14,7 +15,6 @@ import ( | |
| jsonrpc "github.com/smartcontractkit/chainlink-common/pkg/jsonrpc2" | ||
| "github.com/smartcontractkit/chainlink-evm/gethwrappers/workflow/generated/workflow_registry_wrapper_v2" | ||
| "github.com/smartcontractkit/chainlink/v2/core/capabilities/vault/vaulttypes" | ||
| "github.com/smartcontractkit/chainlink/v2/core/capabilities/vault/vaultutils" | ||
| "github.com/smartcontractkit/chainlink/v2/core/logger" | ||
| syncerv2mocks "github.com/smartcontractkit/chainlink/v2/core/services/workflows/syncer/v2/mocks" | ||
| ) | ||
|
|
@@ -153,22 +153,15 @@ func testAuthForRequests(t *testing.T, allowlistedRequest, notAllowlistedRequest | |
| mockSyncer := syncerv2mocks.NewWorkflowRegistrySyncer(t) | ||
| auth := NewRequestAuthorizer(lggr, mockSyncer) | ||
|
|
||
| // Invalid method | ||
| invalidReq := jsonrpc.Request[json.RawMessage]{ | ||
| Method: "invalid-method", | ||
| Params: nil, | ||
| } | ||
| isAuthorized, _, err := auth.AuthorizeRequest(context.Background(), invalidReq) | ||
| require.ErrorContains(t, err, "unauthorized method: invalid-method") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whether the method is valid is checked in the handler, not the authorizer. |
||
| require.False(t, isAuthorized) | ||
|
|
||
| // Happy path | ||
| digest, err := vaultutils.DigestForRequest(allowlistedRequest) | ||
| digest, err := allowlistedRequest.Digest() | ||
| require.NoError(t, err) | ||
| digestBytes, err := hex.DecodeString(digest) | ||
| require.NoError(t, err) | ||
| expiry := uint64(time.Now().UTC().Unix() + 100) //nolint:gosec // it is a safe conversion | ||
| allowlisted := []workflow_registry_wrapper_v2.WorkflowRegistryOwnerAllowlistedRequest{ | ||
| { | ||
| RequestDigest: digest, | ||
| RequestDigest: [32]byte(digestBytes), | ||
| Owner: owner, | ||
| ExpiryTimestamp: uint32(expiry), //nolint:gosec // it is a safe conversion | ||
| }, | ||
|
|
||
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Ack, this is the core change. we removed our customized DigestForRequest() and use the default Digest() from jsonrpc.