Skip to content

Commit

Permalink
fix(coap-server): ignore incoming requests with an invalid source port (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
JKRhb authored Dec 12, 2023
1 parent 1db1c11 commit f22fe0c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/binding-coap/src/coap-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,14 @@ export default class CoapServer implements ProtocolServer {
}

private async handleRequest(req: IncomingMessage, res: OutgoingMessage) {
const sourcePort = req.rsinfo.port;
const hasInvalidPortRange = sourcePort < 1 || sourcePort > 65535;
if (hasInvalidPortRange) {
// Ignore requests with an invalid source port
// See https://github.com/eclipse-thingweb/node-wot/issues/1182
return;
}

const origin = this.formatRequestOrigin(req);

debug(
Expand Down

0 comments on commit f22fe0c

Please sign in to comment.