hyperledger / hyperledger/fabric
Invalid endorsement policies set on keys using state based endorsement should not be possible
- Dominant language
- Go
- Stars
- 16.7k
- Forks
- 9.1k
- Avg merge
- 5h 38m
- Merged PRs (30d)
- 26
Description
Inspired by a recent fabric mailing list question and this jira https://jira.hyperledger.org/browse/FAB-18090
Looking at node, the call to set an endorsment policy on a key is
```
/**
* Sets the key-level endorsement policy for `key`
*
* @async
* @param {string} key State variable key to set endorsement policy
* @param {Buffer} ep endorsement policy
*/
async setStateValidationParameter(key, ep) {
```
and in Go it's defined as
```
SetStateValidationParameter(key string, ep []byte) error
```
On node at least it appears you can provide any binary content for the endorsement policy and no error occurs when the api is called
The transaction further is committed as valid and you are then left with a key that has an unknown endorsement policy definition. This can then cause problems using this key with errors such as
```
peer0.org1.example.com|2021-12-07 16:48:02.692 UTC [vscc] Validate -> ERRO 07f VSCC error: stateBasedValidator.Validate failed, err unexpected EOF
peer0.org1.example.com|2021-12-07 16:48:02.693 UTC [committer.txvalidator] validateTx -> ERRO 080 Dispatch for transaction txId = a71b283ffeb35acf104bf611a9fabbe342caefa88ef5ae6c0dbee0598dc229de returned error: unexpected EOF
peer0.org1.example.com|2021-12-07 16:48:02.693 UTC [gossip.privdata] StoreBlock -> ERRO 081 Validation failed: unexpected EOF channel=mychannel
peer0.org1.example.com|2021-12-07 16:48:02.693 UTC [gossip.state] commitBlock -> ERRO 082 Got error while committing(unexpected EOF
peer0.org1.example.com|github.com/hyperledger/fabric/gossip/state.(*GossipStateProviderImpl).commitBlock
peer0.org2.example.com|2021-12-07 16:48:02.693 UTC [vscc] Validate -> ERRO 07e VSCC error: stateBasedValidator.Validate failed, err unexpected EOF
peer0.org1.example.com| /go/src/github.com/hyperledger/fabric/gossip/state/state.go:805
peer0.org1.example.com|github.com/hyperledger/fabric/gossip/state.(*GossipStateProviderImpl).deliverPayloads
peer0.org1.example.com| /go/src/github.com/hyperledger/fabric/gossip/state/state.go:577
peer0.org1.example.com|runtime.goexit
peer0.org1.example.com| /usr/local/go/src/runtime/asm_amd64.s:1374)
peer0.org1.example.com|2021-12-07 16:48:02.693 UTC [gossip.state] deliverPayloads -> ERRO 083 Failed executing VSCC due to unexpected EOF. Aborting chain processing
peer0.org2.example.com|2021-12-07 16:48:02.693 UTC [committer.txvalidator] validateTx -> ERRO 07f Dispatch for transaction txId = a71b283ffeb35acf104bf611a9fabbe342caefa88ef5ae6c0dbee0598dc229de returned error: unexpected EOF
peer0.org2.example.com|2021-12-07 16:48:02.693 UTC [gossip.privdata] StoreBlock -> ERRO 080 Validation failed: unexpected EOF channel=mychannel
peer0.org2.example.com|2021-12-07 16:48:02.693 UTC [gossip.state] commitBlock -> ERRO 081 Got error while committing(unexpected EOF
peer0.org2.example.com|github.com/hyperledger/fabric/gossip/state.(*GossipStateProviderImpl).commitBlock
peer0.org2.example.com| /go/src/github.com/hyperledger/fabric/gossip/state/state.go:805
peer0.org2.example.com|github.com/hyperledger/fabric/gossip/state.(*GossipStateProviderImpl).deliverPayloads
peer0.org2.example.com| /go/src/github.com/hyperledger/fabric/gossip/state/state.go:577
peer0.org2.example.com|runtime.goexit
peer0.org2.example.com| /usr/local/go/src/runtime/asm_amd64.s:1374)
peer0.org2.example.com|2021-12-07 16:48:02.693 UTC [gossip.state] deliverPayloads -> ERRO 082 Failed executing VSCC due to unexpected EOF. Aborting chain processing
```
It may even cause the channel to become useable, failing on any key
The first issue here is what constitutes an invalid endorsement policy:
1. Where the endorsement policy provided is constructed in the correct format but the information in it is not correct, eg unknown MspId or principle
2. Where the endorsement policy provided is not constructed in the correct format, which could be complete garbage such as a random string
Using SBEs means you have to be really careful to make sure you get the information correct as fabric provides no protection against making a mistake
Contributor guide
Assessment
This issue has not been assessed yet.