Skip to content

fix(fabric)!: verify endorsement signatures, proposal hash and read version of state certifications - #2038

Merged
SaidAltury-ibm merged 1 commit into
hyperledger-labs:mainfrom
SaidAltury-ibm:fix/1997-verify-certification-endorsements
Oct 12, 2026
Merged

SaidAltury-ibm merged 1 commit into
hyperledger-labs:mainfrom
SaidAltury-ibm:fix/1997-verify-certification-endorsements

Conversation

@SaidAltury-ibm

@SaidAltury-ibm SaidAltury-ibm commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

A responder accepted a counterparty's input certification once the envelope's proposal responses named the discovered endorsers: no signature was verified, the function and arguments were not bound to the endorsements, and the certified value was not tied to the version the transaction reads.

Transaction.HasBeenEndorsedBy now requires, for each party, a proposal response that names it, endorses the same payload as the first response, and carries a valid signature by it, verified with the transaction's verifier providers and the channel MSP, as when endorsements are collected. It returns an error when called with no parties or when no verifier provider is available. The error names the failed check and, for a signature, carries the error of every verifier provider tried.

The function and arguments of a transaction are read from its signed proposal or envelope, while the endorsements sign the proposal hash (generic) or the transaction ID (fabricx) in the proposal responses. SetFromEnvelopeBytes in both drivers rejects an envelope whose endorsed proposal hash is not the hash of its channel header, signature header and chaincode proposal payload; UnpackedEnvelope exposes both hashes. SetFromBytes in both drivers rejects a transaction that carries proposal responses without a signed proposal; the generic driver rejects a response that endorses a different proposal than the signed one, and the fabricx driver a response for a different transaction ID.

ChaincodeCertifier requires the certification's read of the key to be at the version the transaction reads it at, compared with vault.Equal so that a read with no version and a read at the zero version match. driver.RWSet gains GetReadVersion for this, implemented by the generic vault Interceptor and Inspector and the fabricx RWSet.

SetVerifierProviders documents that its providers apply to the collection only.

Fixes #1997

BREAKING CHANGE: driver.RWSet in platform/common/driver has a new method, GetReadVersion(ns, key) (RawVersion, error); implementations and mocks of the interface must add it. endorser.Transaction.HasBeenEndorsedBy returns an error when called with no parties, and for a party whose proposal response endorses another payload or whose signature does not verify against the transaction's verifier providers or the channel MSP; it does not consult the providers passed to the collect view's SetVerifierProviders, so register those with Transaction.AppendVerifierProvider as well. SetFromEnvelopeBytes in the generic and fabricx drivers returns an error for an envelope whose proposal hash does not match the endorsed one. SetFromBytes in both drivers returns an error for a transaction that carries proposal responses without a signed proposal, or a response that does not endorse its signed proposal (generic) or transaction ID (fabricx); a flow that collects endorsements from several remote parties before endorsing locally must call EndorseProposal first.

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Hey @SaidAltury-ibm 👋 thanks for the PR!
I'm your friendly PR Helper Bot 🤖 and I'll be riding shotgun on this one, keeping track of your PR's status to help you get it approved and merged.

This comment updates automatically as you push changes -- think of it as your PR's live scoreboard!
Here's the latest:


PR Checks

✅ DCO Sign-off -- All commits have valid sign-offs. Nice work!


❌ GPG Signature -- Heads up! The following commits don't have a verified GPG signature:

  • f1926c9 fix(fabric)!: verify endorsement signatures, proposal hash and read version of state certifications

You'll need to sign your commits with GPG (e.g. git commit -S). See the Signing Guide for a step-by-step walkthrough.


✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing!


✅ Issue Link -- Linked to #1997 (assigned to you).


⏳ All checks must pass before this PR can be reviewed. You've got this!

@github-actions github-actions Bot added the status: needs review The pull request is ready for maintainer review label Oct 4, 2026
@SaidAltury-ibm SaidAltury-ibm added this to the 26Q4 milestone Oct 4, 2026

@AkramBitar AkramBitar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified the new proposal-hash computation matches Fabric's GetProposalHash1/GetProposalHash2 (channel header || signature header || transient-stripped chaincode proposal payload), so envelopes built by CreateSignedTx/CreateEndorserTX and by real peers still load; all modules build and the affected unit test packages are green. Three findings inline, plus one below.

medium platform/fabricx/core/transaction/transaction.go:198 (no hunk in this diff) still carries // TODO: check the current payload is compatible with the content of the signed proposal and performs no proposal-hash check, although it calls the same transaction.UnpackEnvelopeFromBytes that now exposes both hashes. Since endorser.NewTransactionFromEnvelopeBytes resolves the transaction manager from the network at runtime, the gap this PR closes stays open on Fabric-X: function and arguments are read from an envelope its endorsements do not cover. Note the fix is not a copy of the generic check — fabricx's getProposalResponse puts rawTx (an applicationpb.Tx) in ProposalResponse.Payload rather than a ProposalResponsePayload, so EndorsedProposalHash is meaningless there and the binding needs to be expressed against the Fabric-X payload.

@SaidAltury-ibm
SaidAltury-ibm force-pushed the fix/1997-verify-certification-endorsements branch from a22439a to 7893d72 Compare October 11, 2026 10:25
@SaidAltury-ibm

Copy link
Copy Markdown
Contributor Author

Thanks @AkramBitar, all three addressed in 7893d72 (squashed).

  • fabricx SetFromBytes (r4217719585): added the binding you suggested. Every proposal response's Response.Payload must equal the signed proposal's txID, and the TODO is gone. fabricx endorsers sign only the namespaces and the txID, so this pins the responses to the transaction; function and args are not endorsed in fabricx by design.
  • Omitted signed proposal (r4217721784): both drivers now reject a transaction that carries proposal responses but no signed proposal. Every in-repo collection endorses locally first, and Panurus calls EndorseProposal before collecting, so legitimate flows always carry the signed proposal. The remaining edge (several remote parties before any local endorsement, without EndorseProposal) is listed in the BREAKING CHANGE note.
  • SetVerifierProviders (r4217722021): this is intended. The collect view's providers apply to that collection only, and copying them onto the transaction would widen the trust of every later HasBeenEndorsedBy call. I added it to the BREAKING CHANGE note with the migration (AppendVerifierProvider).

@SaidAltury-ibm
SaidAltury-ibm force-pushed the fix/1997-verify-certification-endorsements branch from 7893d72 to a267e33 Compare October 12, 2026 09:38
@github-actions github-actions Bot added status: needs revision The pull request requires changes from the author before it can be reviewed or merged and removed status: needs review The pull request is ready for maintainer review labels Oct 12, 2026

@AkramBitar AkramBitar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

KGTM

@mergify

mergify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@SaidAltury-ibm
SaidAltury-ibm force-pushed the fix/1997-verify-certification-endorsements branch from a267e33 to 641931f Compare October 12, 2026 12:08
@SaidAltury-ibm
SaidAltury-ibm enabled auto-merge (squash) October 12, 2026 12:18
@SaidAltury-ibm
SaidAltury-ibm force-pushed the fix/1997-verify-certification-endorsements branch from 641931f to cf5a46c Compare October 12, 2026 12:18
…ersion of state certifications

A responder accepted a counterparty's input certification once the envelope's proposal responses named the discovered endorsers: no signature was verified, the function and arguments were not bound to the endorsements, and the certified value was not tied to the version the transaction reads.

Transaction.HasBeenEndorsedBy now requires, for each party, a proposal response that names it, endorses the same payload as the first response, and carries a valid signature by it, verified with the transaction's verifier providers and the channel MSP, as when endorsements are collected. It returns an error when called with no parties or when no verifier provider is available. The error names the failed check and, for a signature, carries the error of every verifier provider tried.

The function and arguments of a transaction are read from its signed proposal or envelope, while the endorsements sign the proposal hash (generic) or the transaction ID (fabricx) in the proposal responses. SetFromEnvelopeBytes in both drivers rejects an envelope whose endorsed proposal hash is not the hash of its channel header, signature header and chaincode proposal payload; UnpackedEnvelope exposes both hashes. SetFromBytes in both drivers rejects a transaction that carries proposal responses without a signed proposal; the generic driver rejects a response that endorses a different proposal than the signed one, and the fabricx driver a response for a different transaction ID.

ChaincodeCertifier requires the certification's read of the key to be at the version the transaction reads it at, compared with vault.Equal so that a read with no version and a read at the zero version match. driver.RWSet gains GetReadVersion for this, implemented by the generic vault Interceptor and Inspector and the fabricx RWSet.

SetVerifierProviders documents that its providers apply to the collection only.

Fixes hyperledger-labs#1997

BREAKING CHANGE: driver.RWSet in platform/common/driver has a new method, GetReadVersion(ns, key) (RawVersion, error); implementations and mocks of the interface must add it. endorser.Transaction.HasBeenEndorsedBy returns an error when called with no parties, and for a party whose proposal response endorses another payload or whose signature does not verify against the transaction's verifier providers or the channel MSP; it does not consult the providers passed to the collect view's SetVerifierProviders, so register those with Transaction.AppendVerifierProvider as well. SetFromEnvelopeBytes in the generic and fabricx drivers returns an error for an envelope whose proposal hash does not match the endorsed one. SetFromBytes in both drivers returns an error for a transaction that carries proposal responses without a signed proposal, or a response that does not endorse its signed proposal (generic) or transaction ID (fabricx); a flow that collects endorsements from several remote parties before endorsing locally must call EndorseProposal first.

Signed-off-by: Said Altury <Said.Altury@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs revision The pull request requires changes from the author before it can be reviewed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(fabric): state-input certification accepts forged endorsements because no signature on the certification envelope is verified

2 participants