A vulnerability was found in the ping functionality of the ws module before 1.0.0 which allowed clients to allocate memory by sending a…
hackerone·CWE-201·Published 2018-05-31
A vulnerability was found in the ping functionality of the ws module before 1.0.0 which allowed clients to allocate memory by sending a ping frame. The ping functionality by default responds with a pong frame and the previously given payload of the ping frame. This is exactly what you expect, but internally ws always transforms all data that we need to send to a Buffer instance and that is where the vulnerability existed. ws didn't do any checks for the type of data it was sending. With buffers in node when you allocate it when a number instead of a string it will allocate the amount of bytes.
A vulnerability was found in the ping functionality of the ws module before 1.0.0 which allowed clients to allocate memory by sending a ping frame. The ping functionality by default responds with a pong frame and the previously given payload of the ping frame. This is exactly what you expect, but internally ws always transforms all data that we need to send to a Buffer instance and that is where the vulnerability existed. ws didn't do any checks for the type of data it was sending. With buffers in node when you allocate it when a number instead of a string it will allocate the amount of bytes.
Versions of `ws` prior to 1.0.1 are affected by a remote memory disclosure vulnerability. In certain rare circumstances, applications which allow users to control the arguments of a `client.ping()` call will cause `ws` to send the contents of an allocated but non-zero-filled buffer to the server. This may disclose sensitive information that still exists in memory after previous use of the memory for other tasks. ## Proof of Concept ``` var ws = require('ws') var server = new ws.Server({ port: 9000 }) var client = new ws('ws://localhost:9000') client.on('open', function () { console.log('open') client.ping(50) // this sends a non-zeroed buffer of 50 bytes client.on('pong', function (data) { console.log('got pong') console.log(data) // Data from the client. }) }) ``` ## Recommendation Update to version 1.0.1 or greater.
Versions of `ws` prior to 1.0.1 are affected by a remote memory disclosure vulnerability. In certain rare circumstances, applications which allow users to control the arguments of a `client.ping()` call will cause `ws` to send the contents of an allocated but non-zero-filled buffer to the server. This may disclose sensitive information that still exists in memory after previous use of the memory for other tasks. ## Proof of Concept ``` var ws = require('ws') var server = new ws.Server({ port: 9000 }) var client = new ws('ws://localhost:9000') client.on('open', function () { console.log('open') client.ping(50) // this sends a non-zeroed buffer of 50 bytes client.on('pong', function (data) { console.log('got pong') console.log(data) // Data from the client. }) }) ``` ## Recommendation Update to version 1.0.1 or greater.
Se ha encontrado una vulnerabilidad en la funcionalidad ping del módulo ws en versiones anteriores a la 1.0.0 que permite que los clientes asignen memoria mediante el envío de un frame ping. Por defecto, la funcionalidad ping responde con un frame pong y la carga útil dada anteriormente del frame ping. Esto es exactamente lo que se espera, pero, internamente, ws siempre transforma todos los datos que se necesitan enviar a una instancia Buffer, donde existía la vulnerabilidad. ws no realizó ninguna comprobación para el tipo de datos que estaba enviando. Con los búfers en node, cuando se asigna con un número en lugar de una cadena, asignará la cantidad de bytes.
| Version | Type | Source | Base | Exp | Impact | Vector |
|---|---|---|---|---|---|---|
| 2.0 | Primary | NVD | 5.0 | 10.0 | 2.9 | AV:N/AC:L/Au:N/C:P/I:N/A:N |
| 3.0 | Primary | NVD | 7.5 | 3.9 | 3.6 | CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |