Skip to content

fix(fabric): resolve a txID shadowed by a forged envelope in ledger lookups - #2523

Merged
mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:fix-ledger-shadowed-txid
Nov 5, 2026
Merged

mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:fix-ledger-shadowed-txid

Conversation

@mbrandenburger

Copy link
Copy Markdown
Member

Fixes #2522.

A block can carry an invalid envelope forged with the txID of an honest one that follows it, and the honest envelope still validates (#2482, #2487). qscc's GetTransactionByID returns the first envelope Fabric indexed for a txID: blockIndex.getTxIDVal takes the lowest (blkNum, txNum) key, and kvLedger.GetTransactionByID reads both the envelope and its flag from that entry. So Ledger.GetTransactionByID returned the forgery, flagged BAD_PROPOSAL_TXID or, for a MESSAGE forgery, UNSUPPORTED_TX_PAYLOAD, for a transaction that committed Valid. In Panurus, recovery then deletes the transaction from the token store (LFDT-Panurus/panurus#2647).

Changes:

  • When the lookup returns an invalid envelope, GetTransactionByID fetches its block with GetBlockByTxID and returns the valid endorser transaction with the same txID if the block has one, the rule of committer.ShadowedEnvelopes. Only that block can hold the honest envelope, because Fabric flags a later one DUPLICATE_TXID.
  • Both queries go to the same peer. PickPeer picks at random, and another peer may not have committed the block yet.
  • NewProcessedTransaction rejects a non-endorser envelope, so the twin is looked for before that error is returned. Without a twin, the error is returned as before.
  • A block that cannot be fetched or parsed is an error, not the invalid verdict, so callers retry instead of acting on a forgery. This also applies to an honestly invalid transaction.
  • A valid lookup is unchanged and issues no block query. An invalid one costs one more qscc query.
  • The ShadowedEnvelopes Godoc and security-model.md list ledger lookups among the paths that apply the rule. The rule is documented on the Fabric implementation, not on driver.Ledger, which Fabric-x also implements.

Tests:

  • TestGetTransactionByIDShadowed covers a forged endorser or MESSAGE envelope ahead of the honest one, an unparsable envelope before the twin, no twin, an invalid twin, a valid config twin, a twin past the validation flags, no flags, a MESSAGE forgery without a twin, a failed or unparsable block, and a valid lookup. Each case checks the number of block queries, and that both queries go to one peer.
  • The cases fail when the fix is removed, and when the type check, the flag check, the bounds check, the block error or the single-peer pick is removed.

Not breaking: no signature changes. Once this is in an FSC release, Panurus needs only the FSC bump; LFDT-Panurus/panurus#2653 can shrink to its regression tests.

make checks is clean and the platform/fabric/... unit tests pass with -race.

@mbrandenburger mbrandenburger added this to the 26Q4 milestone Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Hey @mbrandenburger 👋 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:

  • 3519dcf fix(fabric): resolve a txID shadowed by a forged envelope in ledger lookups

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 #2522 (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 revision The pull request requires changes from the author before it can be reviewed or merged label Nov 5, 2026
@mbrandenburger

Copy link
Copy Markdown
Member Author

CC @Effi-S

@mergify

mergify Bot commented Nov 5, 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.

@mbrandenburger
mbrandenburger enabled auto-merge (squash) November 5, 2026 13:59
…ookups

A block can carry an invalid envelope forged with the txID of an honest
one that follows it, and the honest envelope still validates. qscc's
GetTransactionByID returns the first envelope Fabric indexed for a
txID, which is the forgery, so Ledger.GetTransactionByID reported
BAD_PROPOSAL_TXID, or UNSUPPORTED_TX_PAYLOAD for a MESSAGE forgery, for
a transaction that committed Valid. Panurus recovery then deleted the
transaction from the token store.

When the lookup returns an invalid envelope, GetTransactionByID fetches
its block with GetBlockByTxID and returns the valid endorser
transaction with the same txID if the block has one, the rule of
committer.ShadowedEnvelopes. Only that block can hold the honest
envelope, because Fabric flags a later one DUPLICATE_TXID.

- Both queries go to the same peer. PickPeer picks at random, and
  another peer may not have the block yet.
- The twin is looked for before a non-endorser forgery's parse error is
  returned; without a twin that error is returned as before.
- A block that cannot be fetched or parsed is an error, not the
  invalid verdict, so callers retry instead of acting on a forgery.
- A valid lookup is unchanged and issues no block query.

The ShadowedEnvelopes Godoc and the security model list ledger lookups
among the paths that apply the rule.

Fixes hyperledger-labs#2522

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
@mbrandenburger
mbrandenburger force-pushed the fix-ledger-shadowed-txid branch from 75483fd to 3519dcf Compare November 5, 2026 14:03
@github-actions github-actions Bot added the fix label Nov 5, 2026
@mbrandenburger
mbrandenburger merged commit ffe3b7f into hyperledger-labs:main Nov 5, 2026
@mbrandenburger
mbrandenburger deleted the fix-ledger-shadowed-txid branch November 5, 2026 14:03
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

👋 Hi @mbrandenburger! Great work on your recent contribution! 🎉

Here are some issues you might want to explore next:

Happy coding! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 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.

Resolve a txID shadowed by a forged envelope in ledger lookups

2 participants