Browse Source

Fix crypto/merkle ProofOperators.Verify to check bounds on keypath pa… (#2756)

* Fix crypto/merkle ProofOperators.Verify to check bounds on keypath parts.

* Update PENDING
pull/2762/head v0.26.1-rc0
Jae Kwon 6 years ago
committed by Ethan Buchman
parent
commit
03e42d2e38
3 changed files with 9 additions and 0 deletions
  1. +2
    -0
      CHANGELOG_PENDING.md
  2. +3
    -0
      crypto/merkle/proof.go
  3. +4
    -0
      crypto/merkle/proof_test.go

+ 2
- 0
CHANGELOG_PENDING.md View File

@ -25,4 +25,6 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
### IMPROVEMENTS:
### BUG FIXES:
- [crypto/merkle] [\#2756](https://github.com/tendermint/tendermint/issues/2756) Fix crypto/merkle ProofOperators.Verify to check bounds on keypath parts.
- [mempool] fix a bug where we create a WAL despite `wal_dir` being empty

+ 3
- 0
crypto/merkle/proof.go View File

@ -43,6 +43,9 @@ func (poz ProofOperators) Verify(root []byte, keypath string, args [][]byte) (er
for i, op := range poz {
key := op.GetKey()
if len(key) != 0 {
if len(keys) == 0 {
return cmn.NewError("Key path has insufficient # of parts: expected no more keys but got %+v", string(key))
}
lastKey := keys[len(keys)-1]
if !bytes.Equal(lastKey, key) {
return cmn.NewError("Key mismatch on operation #%d: expected %+v but got %+v", i, string(lastKey), string(key))


+ 4
- 0
crypto/merkle/proof_test.go View File

@ -107,6 +107,10 @@ func TestProofOperators(t *testing.T) {
err = popz.Verify(bz("OUTPUT4"), "//KEY4/KEY2/KEY1", [][]byte{bz("INPUT1")})
assert.NotNil(t, err)
// BAD KEY 5
err = popz.Verify(bz("OUTPUT4"), "/KEY2/KEY1", [][]byte{bz("INPUT1")})
assert.NotNil(t, err)
// BAD OUTPUT 1
err = popz.Verify(bz("OUTPUT4_WRONG"), "/KEY4/KEY2/KEY1", [][]byte{bz("INPUT1")})
assert.NotNil(t, err)


Loading…
Cancel
Save