Skip to content

Commit f22fe0c

Browse files
authored
fix(coap-server): ignore incoming requests with an invalid source port (#1188)
* fix(coap-server): ignore incoming messages with an invalid source port * fixup! fix(coap-server): ignore incoming messages with an invalid source port * fixup! fix(coap-server): ignore incoming messages with an invalid source port
1 parent 1db1c11 commit f22fe0c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/binding-coap/src/coap-server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,14 @@ export default class CoapServer implements ProtocolServer {
435435
}
436436

437437
private async handleRequest(req: IncomingMessage, res: OutgoingMessage) {
438+
const sourcePort = req.rsinfo.port;
439+
const hasInvalidPortRange = sourcePort < 1 || sourcePort > 65535;
440+
if (hasInvalidPortRange) {
441+
// Ignore requests with an invalid source port
442+
// See https://github.com/eclipse-thingweb/node-wot/issues/1182
443+
return;
444+
}
445+
438446
const origin = this.formatRequestOrigin(req);
439447

440448
debug(

0 commit comments

Comments
 (0)