Skip to content

consenus/PeerState: SetHasProposal could be exploited by a malicious peer to crash node since common.BitArray doesn't catch negative lengths before makeslice #1322

@odeke-em

Description

@odeke-em

I was just auditing the code to check for how a peer could take down all it's peers in one take and I found a way. By broadcasting to all of them a Proposal of a blockstate with a Total <= -127 a malicious peer can take down all of it's peers because:

case DataChannel:
if conR.FastSync() {
conR.Logger.Info("Ignoring message received during fastSync", "msg", msg)
return
}
switch msg := msg.(type) {
case *ProposalMessage:
ps.SetHasProposal(msg.Proposal)
conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()}

ps.ProposalBlockParts = cmn.NewBitArray(proposal.BlockPartsHeader.Total)

but then see the code in tendermint/tmlibs/common.NewBitArray https://github.com/tendermint/tmlibs/blob/1b9b5652a199ab0be2e781393fb275b66377309d/common/bit_array.go#L16-L25
screen shot 2018-03-17 at 8 43 50 pm

and notice the line https://github.com/tendermint/tmlibs/blob/1b9b5652a199ab0be2e781393fb275b66377309d/common/bit_array.go#L18-L20
screen shot 2018-03-17 at 8 44 42 pm

Which will then crash with

panic: runtime error: makeslice: len out of range [recovered]
	panic: runtime error: makeslice: len out of range

goroutine 20 [running]:
testing.tRunner.func1(0xc0001560f0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    T:securityType: Security (specify priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions