Skip to content

fix(fabric): guard remaining unsafe protobuf field accesses - #1906

Merged
SaidAltury-ibm merged 2 commits into
hyperledger-labs:mainfrom
mbrandenburger:1861-protobuf-getter-audit
Sep 27, 2026
Merged

SaidAltury-ibm merged 2 commits into
hyperledger-labs:mainfrom
mbrandenburger:1861-protobuf-getter-audit

Conversation

@mbrandenburger

@mbrandenburger mbrandenburger commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Replaces direct pointer-field dereferences with nil-safe Get*() accessors (or an explicit nil guard, matching each file's existing sibling style), so a malformed or partially-populated protobuf message is reported as an error instead of panicking:
    • chaincode/invoke.go: ProposalResponse.Response
    • rwset/loader.go, fabricx/ledger.go, fabricx/transaction/envelope.go: Payload.Header
    • generic/transaction/envelope.go: Payload.Header (explicit guard)
    • protoutil/txutils.go: ProposalResponse.Response
  • Adds a regression test for each fix
  • Fixes a pre-existing assertion in chaincode_test.go that expected a non-empty txID on a Submit() failure path that always returns ""

Fixes #1905.

Test plan

  • go test passes for every touched package (protoutil, rwset, generic/transaction, generic/chaincode, fabricx/ledger, fabricx/transaction)
  • make lint reports 0 issues
  • Each fix has a require.NotPanics regression test demonstrating the historical panic no longer occurs

Replace direct pointer-field dereferences with nil-safe Get*() accessors
(or an explicit nil guard, matching each file's existing sibling style)
so a malformed or partially-populated protobuf message is reported as
an error instead of panicking:

- chaincode/invoke.go: ProposalResponse.Response
- rwset/loader.go and fabricx/ledger.go and fabricx/transaction/envelope.go:
  Payload.Header
- generic/transaction/envelope.go: Payload.Header (explicit guard)
- protoutil/txutils.go: ProposalResponse.Response

Add regression tests for each fix, and fix a pre-existing assertion in
chaincode_test.go that expected a non-empty txID on a Submit() failure
path that always returns "".

Part of hyperledger-labs#1861

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
@github-actions

github-actions Bot commented Sep 25, 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:

  • 10d3cf4 fix(fabric): guard remaining unsafe protobuf field accesses

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 #1905 (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 Sep 25, 2026
@mbrandenburger mbrandenburger added this to the 26Q3 milestone Sep 25, 2026
@mbrandenburger mbrandenburger added status: needs review The pull request is ready for maintainer review and removed status: needs revision The pull request requires changes from the author before it can be reviewed or merged labels Sep 25, 2026
@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 Sep 27, 2026
@mergify

mergify Bot commented Sep 27, 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 merged commit 8b58436 into hyperledger-labs:main Sep 27, 2026
45 checks passed
@mbrandenburger
mbrandenburger deleted the 1861-protobuf-getter-audit branch September 28, 2026 07:32
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.

Panic risk audit follow-up: more unguarded protobuf Get*() accesses

2 participants