ethstats: set readlimit on ethstats server connection (#26207)

This prevents DoS when connected to a malicious ethstats server.
This commit is contained in:
Martin Holst Swende 2022-11-17 15:33:03 +01:00 committed by GitHub
parent 97c563e055
commit c2e0abce2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
@ -121,6 +123,7 @@ type connWrapper struct {
}
func newConnectionWrapper(conn *websocket.Conn) *connWrapper {
conn.SetReadLimit(messageSizeLimit)
return &connWrapper{conn: conn}
}