Skip to content

validate required fields before hashing relay request params#2032

Merged
mchain0 merged 3 commits intomainfrom
tejaswi/relay-request-params-validation
May 7, 2026
Merged

validate required fields before hashing relay request params#2032
mchain0 merged 3 commits intomainfrom
tejaswi/relay-request-params-validation

Conversation

@nadahalli
Copy link
Copy Markdown
Contributor

What changed

  • SecretsRequestParams.Validate() and CapabilityRequestParams.Validate() reject zero-valued required fields (workflow_id, owner, execution_id, enclave_public_key, plus the type-specific binders).
  • Hash() on SecretsResponseResult and CapabilityResponseResult now calls Validate() first and returns ([32]byte, error) so a caller cannot accidentally produce a signature over an unbinding payload.
  • Removes omitempty from CapabilityRequestParams.Owner, .ExecutionID, .ReferenceID. These are the per-request fields that establish replay protection; they should always serialize.

Why

mchain0 flagged on smartcontractkit/chainlink#22302 that execution_id and reference_id were optional, so a relay-DON signature could be bound to a less-unique context than the caller believed and replayed across distinct logical requests that differed only in those fields. This PR closes that hole structurally: Hash() returns an error if any field the canonical hash depends on is empty, so signing an unbinding payload becomes impossible by construction.

Validation

  • go test ./pkg/capabilities/v2/actions/confidentialrelay/

Downstream

Caller updates land separately:

@nadahalli nadahalli requested a review from a team as a code owner May 5, 2026 16:24
Copilot AI review requested due to automatic review settings May 5, 2026 16:24
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

👋 nadahalli, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

⚠️ API Diff Results - github.com/smartcontractkit/chainlink-common

⚠️ Breaking Changes (2)

pkg/capabilities/v2/actions/confidentialrelay.(*CapabilityResponseResult) (1)
  • Hash — Type changed:
func(
  CapabilityRequestParams
)
- [32]byte
+ ([32]byte, error)
pkg/capabilities/v2/actions/confidentialrelay.(*SecretsResponseResult) (1)
  • Hash — Type changed:
func(
  SecretsRequestParams
)
- [32]byte
+ ([32]byte, error)

✅ Compatible Changes (2)

pkg/capabilities/v2/actions/confidentialrelay.CapabilityRequestParams (1)
  • Validate — ➕ Added
pkg/capabilities/v2/actions/confidentialrelay.SecretsRequestParams (1)
  • Validate — ➕ Added

📄 View full apidiff report

@nadahalli nadahalli requested a review from mchain0 May 5, 2026 16:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens confidential relay request/response hashing by validating that all required request fields are non-zero before producing a canonical hash, preventing signatures from being generated over under-binding (replayable) contexts.

Changes:

  • Add Validate() methods for SecretsRequestParams and CapabilityRequestParams and make Hash() reject invalid params.
  • Change SecretsResponseResult.Hash / CapabilityResponseResult.Hash to return ([32]byte, error) and call Validate() internally.
  • Remove omitempty from CapabilityRequestParams.Owner, .ExecutionID, and .ReferenceID to ensure replay-protection fields always serialize.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/capabilities/v2/actions/confidentialrelay/types.go Adds params validation and makes response hashing return an error when required binding fields are empty; updates JSON tags for capability params.
pkg/capabilities/v2/actions/confidentialrelay/types_test.go Refactors hash tests to handle the new error return and adds unit tests for validation + invalid-hash rejection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/capabilities/v2/actions/confidentialrelay/types.go
Comment thread pkg/capabilities/v2/actions/confidentialrelay/types_test.go
Comment thread pkg/capabilities/v2/actions/confidentialrelay/types.go
Comment thread pkg/capabilities/v2/actions/confidentialrelay/types.go
mchain0
mchain0 previously approved these changes May 6, 2026
@mchain0
Copy link
Copy Markdown
Contributor

mchain0 commented May 6, 2026

approving, but minor comments. also I agree with bot suggestions. pls amend

@jmank88 jmank88 requested a review from a team May 7, 2026 11:24
@jmank88 jmank88 requested a review from mchain0 May 7, 2026 11:33
@mchain0 mchain0 added this pull request to the merge queue May 7, 2026
Merged via the queue into main with commit 5637bdf May 7, 2026
33 of 34 checks passed
@mchain0 mchain0 deleted the tejaswi/relay-request-params-validation branch May 7, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants