Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store/internal/proofs: CreateNonMembershipProof/CreateMembershipProof panic with empty key #9233

Closed
4 tasks
cuonglm opened this issue Apr 29, 2021 · 1 comment · Fixed by #9235
Closed
4 tasks

Comments

@cuonglm
Copy link
Contributor

cuonglm commented Apr 29, 2021

Summary of Bug

CreateNonMembershipProof/CreateMembershipProof does not validate the key before calling sdkmaps.ProofsFromMap, so they can panic with empty key.

Version

4f4c035

Steps to Reproduce

package main

import (
	"fmt"

	"github.com/cosmos/cosmos-sdk/store/internal/proofs"
)

func main() {
	icp, err := proofs.CreateNonMembershipProof(map[string][]byte{``: nil}, []byte(` `))
	if err != nil {
		panic(err)
	}
	fmt.Println(icp)
}
package main

import (
	"fmt"

	"github.com/cosmos/cosmos-sdk/store/internal/proofs"
)

func main() {
	icp, err := proofs.CreateMembershipProof(map[string][]byte{``: nil}, []byte(``))
	if err != nil {
		panic(err)
	}
	fmt.Println(icp)
}

Discover by https://oss-fuzz.com/testcase-detail/4647668077953024


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@cuonglm
Copy link
Contributor Author

cuonglm commented Apr 29, 2021

cc @odeke-em

odeke-em pushed a commit that referenced this issue May 2, 2021
Otherwise, an empty key as input or present in data can cause a panic at
runtime.

Caught by oss-fuzz: https://oss-fuzz.com/testcase-detail/4647668077953024

Fixes #9233
mergify bot pushed a commit that referenced this issue May 2, 2021
Otherwise, an empty key as input or present in data can cause a panic at
runtime.

Caught by oss-fuzz: https://oss-fuzz.com/testcase-detail/4647668077953024

Fixes #9233

(cherry picked from commit 711976e)

# Conflicts:
#	CHANGELOG.md
alessio pushed a commit that referenced this issue May 6, 2021
…9235) (#9247)

Fixes #9233

(cherry picked from commit 711976e)
Co-authored-by: Cuong Manh Le <[email protected]>
Co-authored-by: Amaury M <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant