Repository navigation
fix(fabric)!: verify endorsement signatures, proposal hash and read version of state certifications - #2038
Conversation
|
Hey @SaidAltury-ibm 👋 thanks for the PR! This comment updates automatically as you push changes -- think of it as your PR's live scoreboard! 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:
You'll need to sign your commits with GPG (e.g. ✅ 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! |
AkramBitar
left a comment
There was a problem hiding this comment.
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.
a22439a to
7893d72
Compare
|
Thanks @AkramBitar, all three addressed in 7893d72 (squashed).
|
7893d72 to
a267e33
Compare
|
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. |
a267e33 to
641931f
Compare
641931f to
cf5a46c
Compare
…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>
cf5a46c to
f1926c9
Compare
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.