Skip to content

Commit

Permalink
security: New setting for Socket.IO maxHttpBufferSize
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcLear authored and rhansen committed Feb 15, 2021
1 parent ed93ef5 commit b7e88cb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
* Dependencies are now installed with the `--no-optional` flag to speed
installation. Optional dependencies such as `sqlite3` must now be manually
installed (e.g., `(cd src && npm i sqlite3)`).
* Socket.IO messages are now limited to 1MiB to make denial of service attacks
more difficult. This may cause issues with plugins that send large messages,
e.g., `ep_image_upload`.
* Socket.IO messages are now limited to 10K bytes to make denial of service
attacks more difficult. This may cause issues when pasting large amounts of
text or with plugins that send large messages (e.g., `ep_image_upload`). You
can change the limit via `settings.json`; see `socketIo.maxHttpBufferSize`.
* The top-level `package.json` file, added in v1.8.7, has been removed due to
problematic npm behavior. Whenever you install a plugin you will see the
following benign warnings that can be safely ignored:
Expand Down
11 changes: 11 additions & 0 deletions settings.json.docker
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,17 @@
*/
"socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],

"socketIo": {
/*
* Maximum permitted client message size (in bytes). All messages from
* clients that are larger than this will be rejected. Large values make it
* possible to paste large amounts of text, and plugins may require a larger
* value to work properly, but increasing the value increases susceptibility
* to denial of service attacks (malicious clients can exhaust memory).
*/
"maxHttpBufferSize": 10000
},

/*
* Allow Load Testing tools to hit the Etherpad Instance.
*
Expand Down
11 changes: 11 additions & 0 deletions settings.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,17 @@
*/
"socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],

"socketIo": {
/*
* Maximum permitted client message size (in bytes). All messages from
* clients that are larger than this will be rejected. Large values make it
* possible to paste large amounts of text, and plugins may require a larger
* value to work properly, but increasing the value increases susceptibility
* to denial of service attacks (malicious clients can exhaust memory).
*/
"maxHttpBufferSize": 10000
},

/*
* Allow Load Testing tools to hit the Etherpad Instance.
*
Expand Down
2 changes: 1 addition & 1 deletion src/node/hooks/express/socketio.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
* https://github.com/socketio/socket.io/issues/2276#issuecomment-147184662 (not totally true, actually, see above)
*/
cookie: false,
maxHttpBufferSize: 10E3,
maxHttpBufferSize: settings.socketIo.maxHttpBufferSize,
});

io.on('connect', (socket) => {
Expand Down
12 changes: 12 additions & 0 deletions src/node/utils/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ exports.ssl = false;
**/
exports.socketTransportProtocols = ['xhr-polling', 'jsonp-polling', 'htmlfile'];

exports.socketIo = {
/**
* Maximum permitted client message size (in bytes).
*
* All messages from clients that are larger than this will be rejected. Large values make it
* possible to paste large amounts of text, and plugins may require a larger value to work
* properly, but increasing the value increases susceptibility to denial of service attacks
* (malicious clients can exhaust memory).
*/
maxHttpBufferSize: 10000,
};

/*
* The Type of the database
*/
Expand Down

0 comments on commit b7e88cb

Please sign in to comment.