Skip to content

Commit f11b7f0

Browse files
committed
fix(swarm): ignore announcements from peers with invalid announcement ports.
1 parent ea1e78e commit f11b7f0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/server/swarm.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ class Swarm {
3737
announce (params, cb) {
3838
const self = this
3939
const id = params.type === 'ws' ? params.peer_id : params.addr
40+
41+
// Prevent invalid ports as this can be abused - issue: #512
42+
if (params.port <= 0 || params.port > 65535) {
43+
return cb(new Error('invalid port announced'))
44+
}
45+
4046
// Mark the source peer as recently used in cache
4147
const peer = self.peers.get(id)
4248

0 commit comments

Comments
 (0)