Skip to content

Commit

Permalink
ethstats: set readlimit on ethstats server connection (#26207)
Browse files Browse the repository at this point in the history
This prevents DoS when connected to a malicious ethstats server.
  • Loading branch information
holiman authored Nov 17, 2022
1 parent 97c563e commit c2e0abc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ethstats/ethstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const (
txChanSize = 4096
// chainHeadChanSize is the size of channel listening to ChainHeadEvent.
chainHeadChanSize = 10

messageSizeLimit = 15 * 1024 * 1024
)

// backend encompasses the bare-minimum functionality needed for ethstats reporting
Expand Down Expand Up @@ -121,6 +123,7 @@ type connWrapper struct {
}

func newConnectionWrapper(conn *websocket.Conn) *connWrapper {
conn.SetReadLimit(messageSizeLimit)
return &connWrapper{conn: conn}
}

Expand Down

0 comments on commit c2e0abc

Please sign in to comment.