From 89197a05c43b18cc4569fd178d56e7bb8f403865 Mon Sep 17 00:00:00 2001 From: bcaller Date: Wed, 13 May 2020 06:37:32 +0100 Subject: [PATCH 1/2] fix: prevent DoS (OOM) via massive packets (#95) When maxHttpBufferSize is large (1e8 bytes), a payload of length 100MB can be sent like so: 99999991:422222222222222222222222222222222222222222222... This massive packet can cause OOM via building up many many `ConsOneByteString` objects due to concatenation: 99999989 `ConsOneByteString`s and then converting the massive integer to a `Number`. The performance can be improved to avoid this by using `substring` rather than building the string via concatenation. Below I tried one payload of length 7e7 as the 1e8 payload took so long to process that it timed out before running out of memory. ``` ==== JS stack trace ========================================= 0: ExitFrame [pc: 0x13c5b79] Security context: 0x152fe7b808d1 1: decodeString [0x2dd385fb5d1] [/node_modules/socket.io-parser/index.js:~276] [pc=0xf59746881be](this=0x175d34c42b69 ,0x14eccff10fe1 ) 2: add [0x31fc2693da29] [/node_modules/socket.io-parser/index.js:242] [bytecode=0xa7ed6554889 offset=11](this=0x0a2881be5069 ,0x14eccff10fe1 Date: Sat, 9 Jan 2021 14:51:19 +0100 Subject: [PATCH 2/2] chore(release): 3.3.2 Diff: https://github.com/Automattic/socket.io-parser/compare/3.3.1...3.3.2 --- CHANGELOG.md | 8 ++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c98072..8b1992a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,10 @@ +## [3.3.2](https://github.com/Automattic/socket.io-parser/compare/3.3.1...3.3.2) (2021-01-09) + + +### Bug Fixes + +* prevent DoS (OOM) via massive packets ([#95](https://github.com/Automattic/socket.io-parser/issues/95)) ([89197a0](https://github.com/Automattic/socket.io-parser/commit/89197a05c43b18cc4569fd178d56e7bb8f403865)) + + ## [3.3.1](https://github.com/socketio/socket.io-parser/compare/3.3.0...3.3.1) (2020-09-30) diff --git a/package-lock.json b/package-lock.json index 6718338..e7cdf10 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "socket.io-parser", - "version": "3.3.1", + "version": "3.3.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3b39d68..70857ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "socket.io-parser", - "version": "3.3.1", + "version": "3.3.2", "description": "socket.io protocol parser", "repository": { "type": "git",