Repository navigation
fix(fabric): verify idemix recipients through the channel MSP and bound the verifier cache - #2476
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 #2440 (assigned to you). ⏳ All checks must pass before this PR can be reviewed. You've got this! |
|
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. |
…nd the verifier cache The recipient exchange views verified a recipient identity X with the network's signer service. That service resolves X through the node's local MSPs, so a node could verify an idemix recipient only if it held a credential from the same issuer. It also cached every verifier it deserialized, before the proof was checked, so a peer could grow the node's memory by sending well-formed identities with bogus proofs. If X is a SerializedIdentity of an idemix MSP of the receiver's channel, the views now check that X is valid on the channel and verify its proof with the channel MSP's verifier. The validity check is required: the channel verifier alone deserializes X without checking its credential and accepts a pseudonym with no credential behind it. Every other identity, x509 included, is verified through sig.Service.LookupVerifier, which reuses a registered or cached verifier and otherwise deserializes without caching. fabric.SignerService.LookupVerifier reaches it and falls back to GetVerifier for signer services that lack it. The channel comes from the receiver's own configuration: the new Channel field of ExchangeRecipientIdentitiesView and its responder, set from state.WithChannel, or the network's default channel. RequestRecipientIdentity always uses the default channel. The responder ignores ExchangeRecipientRequest.Channel, since the party being verified would otherwise pick the MSPs that verify it. An unknown channel, or one with no configuration in force, fails the exchange before anything is sent or verified, for x509 recipients too. The responder sends that error to the initiator, and it is not counted as a recipient_proof rejection. Fabric-x shares the generic driver, the sig service and these views, and its channel membership has the same methods, so the same rules apply there. Adds fabric.MSPManager.IsIdemixMSP, unit tests that verify real idemix identities from two issuers against channel MSPs, a test on the Fabric-x membership service showing IsValid refuses a credential-less pseudonym, and documentation in the security model, the metrics catalog and the v0.27 to v0.28 upgrade guide. Closes hyperledger-labs#2440 Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
…and bound the verifier cache fix(fabric): verify idemix recipients through the channel MSP and bound the verifier cache The recipient exchange views verified a recipient identity X with the network's signer service. That service resolves X through the node's local MSPs, so a node could verify an idemix recipient only if it held a credential from the same issuer. It also cached every verifier it deserialized, before the proof was checked, so a peer could grow the node's memory by sending well-formed identities with bogus proofs. An x509 identity (a SerializedIdentity whose IdBytes are PEM), or bytes that are not a SerializedIdentity, are verified through sig.Service.LookupVerifier, which reuses a registered or cached verifier and otherwise deserializes without caching, and never need a channel. fabric.SignerService.LookupVerifier reaches it and falls back to GetVerifier for signer services that lack it. If X is any other SerializedIdentity and its MSP is an idemix MSP of the receiver's channel, X must be valid on the channel and its proof is verified with the channel MSP's verifier. The validity check is required: the channel verifier alone deserializes X without checking its credential and accepts a pseudonym with no credential behind it. Otherwise X goes to LookupVerifier. The channel comes from the receiver's own configuration: the new Channel field of ExchangeRecipientIdentitiesView and its responder, set from state.WithChannel, or the network's default channel. RequestRecipientIdentity uses the default channel. The responder ignores ExchangeRecipientRequest.Channel, since the party being verified would otherwise pick the MSPs that verify it. If X needs the channel and it is unknown or has no configuration in force, X is refused without counting a recipient_proof rejection, and the responder tells the initiator only that the channel is not ready. The local idemix deserializer discarded the SerializedIdentity's MSP ID, so a pseudonym with a valid local credential verified under any MSP ID, for example that of an x509 org. It now refuses an identity whose MSP ID differs from the provider's. A deserializer built from an issuer key alone has no MSP ID and accepts any. Fabric-x shares the generic driver, the sig service and these views, and its channel membership has the same methods, so the same rules apply there. Adds fabric.MSPManager.IsIdemixMSP, unit tests that verify real idemix identities from two issuers against channel MSPs and refuse relabelled and credential-less pseudonyms, a test on the Fabric-x membership service showing IsValid refuses a credential-less pseudonym, and documentation in the security model, the metrics catalog and the v0.27 to v0.28 upgrade guide. Closes hyperledger-labs#2440 Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
…and bound the verifier cache Test that the recipient views do not cache verifiers and that GetVerifier keeps caching; note in the metrics catalog that a channel-not-ready refusal is not counted. Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
21a8b9a to
973e2a9
Compare
Closes #2440.
The recipient exchange views in
platform/fabric/services/state/recipients.goverified a recipient identity X with the network's signer service. A node could therefore verify an idemix recipient only if it held a credential from the same issuer, and every verifier the signer service deserialized stayed in an unbounded cache, before the proof was checked.What changes
SerializedIdentitywhoseIdBytesare PEM), or bytes that are not aSerializedIdentity, go through the newsig.Service.LookupVerifierand never touch the channel.LookupVerifierreuses a registered or cached verifier and otherwise deserializes without caching. The views reach it throughfabric.SignerService.LookupVerifier, which type-asserts the inner service and falls back toGetVerifier, sodriver.SigServiceand its mocks are unchanged.SerializedIdentityneeds the channel to tell whether its MSP is idemix. If it is an idemix MSP of the channel, X must passMSPManager().IsValid(x), and its proof is verified with the channel MSP's verifier, so idemix recipients from any issuer in the channel now verify. Otherwise X goes toLookupVerifier.Channelfield onExchangeRecipientIdentitiesViewandRespondExchangeRecipientIdentitiesView, set fromstate.WithChannel, otherwise the default channel.RequestRecipientIdentityuses the default channel. The responder ignoresExchangeRecipientRequest.Channel.WithChannel) or has no configuration in force (driver.ErrNotInitialized), X is refused without being counted as arecipient_proofrejection, since the cause is local. The responder tells the initiator only that the channel is not ready.core/generic/msp/idemix) now refuses an identity whoseSerializedIdentity.Mspiddiffers from the provider's MSP ID. It used to discard the MSP ID, so a pseudonym with a valid local credential verified under any MSP ID, for example that of an x509 org. A deserializer built from an issuer key alone has no MSP ID and is unchanged.fabric.MSPManager.IsIdemixMSP, plus Godoc onGetVerifiersaying it does not check validity.Differences from the issue
ChannelMembership.GetVerifieronly deserializes the identity, on both Fabric and Fabric-x, and never checks the idemix credential. A pseudonym derived from a random secret key with no credential verifies through it.TestRespondExchange_IdemixWithoutCredentialandTestService_IdemixIsValidRequiresCredential(Fabric-x) cover this, so the views callIsValidfirst.RequestRecipientIdentity, which takes no options, could never succeed there.Fabric-x
Fabric-x uses the same generic driver, sig service and recipient views, and its channel membership has
IsIdemixMSP,IsValidandGetVerifier, so the same rules apply without platform code changes. A test over the real Fabric-xmembership.Servicechecks thatIsValidrefuses a credential-less pseudonym whileGetVerifieraccepts it.Compatibility
ttxand its own idemix package, and importsservices/stateonly forVaultService.Testing
platform/fabric/services/stateverify real idemix identities against channel MSPs built from issuer material only: a recipient from a second issuer in the channel verifies; one with the wrong issuer, or one relabelled with another MSP ID on the local idemix path, is refused; a credential-less pseudonym is refused. Other tests cover the channel choice (the responder ignores the initiator'sChannel,WithChannelreaches the views), the unavailable-channel cases, and that x509 recipients verify with no channel.msp.MSPManagerinstances. The real Fabric-xmembership.Serviceis covered separately, as above. Removing theIsValidcall, the channel path or the MSP-ID check makes the matching tests fail.sig.Service.LookupVerifiertests check that the cache does not grow and that cached verifiers are returned.make checks,make unit-tests-rootandmake integration-tests-fabric-atsapass locally.