Repository navigation
fix(fabric)!: require proof of ownership in the recipient exchange - #2452
Conversation
|
Hey @mbrandenburger 👋 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 #2435 (assigned to you). ⏳ All checks must pass before this PR can be reviewed. You've got this! |
|
Hi @mbrandenburger 👋 — the recent merge of PR #2450 has introduced a merge conflict in this PR. Please resolve the merge conflict so that this PR can be reviewed again. Thank you! |
23077ce to
4fa75a2
Compare
SaidAltury-ibm
left a comment
There was a problem hiding this comment.
thank you @mbrandenburger , i have left one testing comment
| ownerNode, malloryNode := view.Identity("owner-node"), view.Identity("mallory-node") | ||
| x, m := view.Identity("x"), view.Identity("m") | ||
|
|
||
| store, err := mem.NewDriver().NewBinding("", "hijack") |
There was a problem hiding this comment.
This test fails from -count=2 onward:
-count=1: ok
-count=2: FAIL
endorsement_test.go:891: Should be true
require.True(t, endpointService.IsBoundTo(ctx, m, x), "the planted row makes M pass as X")
The "hijack" param names the tables, and the memory driver's sqlite provider is keyed on the DSN (sqlite/persistence.go:56-58), which is fixed for mem.NewDriver() — so every run in the process shares one database and the same hijack tables. Run 1 ends with BindProven(ownerNode, x) applied, run 2 inherits that row, and Mallory's plant can no longer make M pass as X, so the setup assertion fails before the test reaches what it is checking.
Changing the store param (e.g. to t.Name()) does not fix it — I tried, and it still fails at -count=2. The row keys are the identities, not the table name, and those are hard-coded. Making the identities unique per run does work:
u := t.Name() + time.Now().Format("150405.000000000")
ownerNode, malloryNode := view.Identity("owner-node"+u), view.Identity("mallory-node"+u)
x, m := view.Identity("x"+u), view.Identity("m"+u)With that, -count=3 and -race -count=3 -shuffle=on both pass, and the test still guards the attack: neutering BindProven to return nil fails it at :895.
The sibling endpoint tests survive -count=3 because their assertions are idempotent; this one's plant → pass-as-X → BindProven-defeats-it sequence is not — run 1 leaves x proven-bound to ownerNode.
Worth fixing because this is the test that demonstrates the actual end-to-end attack — plant, pass as X, then BindProven defeats it — and it's the one test in this PR that can't be re-run. CI runs -count=1 so it won't catch this, but it will bite whoever next runs -count=N.
There was a problem hiding this comment.
Good catch! It seems we have the same problem in TestGetRejections_NoneRegisteredIsSharedNoop in platform/view/services/security. Will fix that in a separate PR.
|
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. |
The recipient exchange views bound whatever identity the counterparty claimed. A peer could claim another party's recipient identity, receive that party's traffic, and have its own endorsement accepted for that party, because endorsement checks accept an endorser bound to the expected party. Whoever sends a recipient identity X now attaches a signature by X over a payload that names the view and direction, the session and context IDs, and the FSC node identities of both ends. The receiver builds that payload from its own view of the session, verifies it with X's verifier from the network's signer service, and only then binds X to the counterparty's node identity with BindProven. The exchange responder verifies the initiator's proof before it replies. A missing or invalid proof binds nothing and returns an error containing "recipient proof:", and is counted as recipient_proof with one of the reasons missing, incomplete context, no verifier or invalid signature. Node identities are canonicalized in the payload (id.CanonicalIdentity), so both ends sign over the same bytes however each loaded its certificate. SignRecipientProof and VerifyRecipientProof are exported for applications with their own recipient exchange, and fabric.SignerService gains GetVerifier. A node verifies a remote idemix recipient identity only if it holds a credential from the same issuer. For x509, a valid proof shows that the sender holds the key for X, not that X belongs to an MSP. Adds unit tests, a hostile-peer spec in the fault-recovery suites, and documentation in the security and programming models, the metrics catalog and the upgrade guide. BREAKING CHANGE: the recipient exchange messages carry a proof, and a node refuses identities sent without one. Every organization that exchanges recipient identities must upgrade together; the upgrade guide lists which combinations of old and new nodes fail and how. Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
…ange Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
d4ed30b to
9cd9f43
Compare
|
👋 Hi @mbrandenburger! Great work on your recent contribution! 🎉 Here are some issues you might want to explore next: Happy coding! 🚀 |
Fixes #2435. Part of #2432.
Problem
The recipient exchange views (
platform/fabric/services/state/recipients.go) bound whatever recipient identity the counterparty claimed. A peer could claim another party's recipient identity, receive that party's traffic, and have its own endorsement accepted for that party, because endorsement checks accept an endorser bound to the expected party (platform/fabric/services/endorser/endorsement.go).Changes
Proof of ownership (
platform/fabric/services/state/proof.go)RecipientData.Proof, a signature by X over a payload naming the view and direction, the session and context IDs, and the FSC node identities of the signer and the verifier. Each field is length-prefixed, and the payload starts with a zero byte so it can't parse as a proposal or envelope signed by the same key.SignRecipientProofandVerifyRecipientProofare exported for applications with their own recipient exchange. A failure wrapsErrRecipientProof.Recipient views
RequestRecipientIdentity,ExchangeRecipientIdentitiesand their responders attach a proof to every identity they send and verify every identity they receive. The identity is verified with X's verifier from the Fabric network's signer service (newfabric.SignerService.GetVerifier), and only then bound withBindProven(fix(view)!: refuse binding redirects and report binding conflicts #2446) to the counterparty's node identity.recipient proof:. It is counted asrecipient_proof, with one of four fixed reasons:missing,incomplete context,no verifierorinvalid signature.Node identities (
platform/view/services/id)CanonicalIdentityre-encodes a PEM certificate to its canonical form. The payload uses it for both node identities, so both ends sign over the same bytes however each loaded its certificate.Deviations from the issue
None.
Behaviour worth reviewing
RecipientDatais JSON, so an old node ignores the new field, but a new node refuses identities sent without a proof. Every organization that exchanges recipient identities upgrades together. The upgrade guide has a table of which old/new combinations fail and the error each side sees.RespondRequestRecipientIdentityViewwith a preset identity now needs a signer for it in the network's signer service. The upgrade guide's developer section notes it.invalid signaturecan also mean that two honest nodes disagree on a node identity in their configuration. The metrics doc says so, so an operator doesn't read every one as an attack.Breaking change
Wire change in the recipient exchange; see above. Panurus maintainers: heads-up before merge. Panurus's own recipient attestation does not name the verifier node and may need the same treatment.
Tests
proof_test.go: the payload is unambiguous and starts with zero; a valid proof verifies; a wrong verifier node, wrong direction tag, other session, wrong key, missing proof and empty context fields are refused; non-canonical PEM node identities give the same payload.proof_idemix_test.go: a proof by a real idemix identity verifies.recipients_test.go: the responder refuses a missing, relayed or unverifiable proof and verifies before it replies; initiators refuse an unproven reply; a valid proof binds and repairs a planted row; the initiator's resolver fallback; each fixed reason.endorsement_test.go: a hijacker that claimed a party's recipient identity without a proof has its endorsement refused.sig_test.go,identity_test.go:SignerService.GetVerifierandCanonicalIdentity.HostileSpecs"refuses a recipient identity claimed without proof of ownership" (integration/fabric/common/faultrecovery). Alice claims bob's own identity without a proof; bob refuses withrecipient proof: missing, the identity still resolves to bob, and an exchange with proofs still binds each identity to its owner. It runs on Fabric and Fabric-x and fails against code without this change.make checksand the root unit tests pass. Earlier runs offabric-iou,fabric-atsaandfabricx-ioupassed with proofs; CI covers the rest.Docs
docs/platform/view/security-model.md: the proof, what it binds, and the idemix and x509 limits.docs/platform/view/programming-model.md: checking payload claims against the caller, and the exported proof helpers.docs/platform/view/services/monitoring_metrics.md: therecipient_proofkind and its reasons.docs/upgrade/v0.27-to-v0.28.md: the Recipient exchange section with the compatibility table, the coordinated-upgrade note at the top, and the checklist.