{"id":"CVE-2021-39131","aliases":["CVE-2021-39131","GHSA-27wq-qx3q-fxm9"],"related":[],"kind":"vulnerability","state":"published","title":"Improper Handling of Unexpected Data Type in ced","summary":"ced detects character encoding using Google’s compact_enc_det library. In ced v0.1.0, passing data types other than `Buffer` causes the Node.js process to crash. The problem has been patched in ced v1.0.0. As a workaround, before passing an argument to ced, verify it’s a `Buffer` using `Buffer.isBuffer(obj)`.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"ced detects character encoding using Google’s compact_enc_det library. In ced v0.1.0, passing data types other than `Buffer` causes the Node.js process to crash. The problem has been patched in ced v1.0.0. As a workaround, before passing an argument to ced, verify it’s a `Buffer` using `Buffer.isBuffer(obj)`.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nIn ced v0.1.0, passing data types other than `Buffer` causes the Node.js process to crash.\n\n### Patches\n\nThe problem has been patched in [ced v1.0.0](https://github.com/sonicdoe/ced/releases/tag/v1.0.0). You can upgrade from v0.1.0 without any breaking changes.\n\n### Workarounds\n\nBefore passing an argument to ced, verify it’s a `Buffer` using [`Buffer.isBuffer(obj)`](https://nodejs.org/api/buffer.html#buffer_static_method_buffer_isbuffer_obj).\n\n### CVSS score\n\n[CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/RL:O/RC:C](https://www.first.org/cvss/calculator/3.1#CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/RL:O/RC:C)\n\nBase Score: 7.5 (High)\nTemporal Score: 7.2 (High)\n\nSince ced is a library, the scoring is based on the “[reasonable worst-case implementation scenario](https://www.first.org/cvss/v3.1/user-guide#3-7-Scoring-Vulnerabilities-in-Software-Libraries-and-Similar)”, namely, accepting data from untrusted sources over a network and passing it directly to ced. Depending on your specific implementation, the vulnerability’s severity in your program may be different.\n\n### Proof of concept\n\n```js\nconst express = require(\"express\");\nconst bodyParser = require(\"body-parser\");\nconst ced = require(\"ced\");\n\nconst app = express();\n\napp.use(bodyParser.raw());\n\napp.post(\"/\", (req, res) => {\n  const encoding = ced(req.body);\n\n  res.end(encoding);\n});\n\napp.listen(3000);\n```\n\n`curl --request POST --header \"Content-Type: text/plain\" --data foo http://localhost:3000` crashes the server.\n\n### References\n\n- https://github.com/sonicdoe/ced/commit/a4d9f10b6bf1cd468d1a5b9a283cdf437f8bb7b3","format":"markdown","source":"ghsa"},{"lang":"es","text":"ced detecta la codificación de caracteres usando la biblioteca compact_enc_det de Google. En ced versión v0.1.0, pasar tipos de datos distintos a \"Buffer\" hace que el proceso Node.js se bloquee. El problema ha sido parcheado en ced versión v1.0.0. Como solución, antes de pasar un argumento a ced, verifique que es un \"Buffer\" usando \"Buffer.isBuffer(obj)\".","source":"nvd"}],"published":"2021-08-17T19:55:09.000Z","modified":"2026-07-08T06:28:22.894Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:N/I:N/A:P","score":5,"rating":"MEDIUM"}],"cwes":["CWE-241","CWE-755"],"affected":[{"ranges":[{"version":"< 1.0.0","status":"affected"}],"vendor":"sonicdoe","product":"ced","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.0.0"}],"ecosystem":"npm","package":"ced","purl":"pkg:npm/ced","source":"ghsa"},{"ranges":[{"status":"affected","version":"0.1.0"}],"vendor":"ced_project","product":"ced","cpe":"cpe:2.3:a:ced_project:ced:0.1.0:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/sonicdoe/ced/security/advisories/GHSA-27wq-qx3q-fxm9","tags":["exploit","patch","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sonicdoe/ced/commit/a4d9f10b6bf1cd468d1a5b9a283cdf437f8bb7b3","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sonicdoe/ced/releases/tag/v1.0.0","tags":["release-notes","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-39131","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/sonicdoe/ced","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-39131","url":"https://www.cve.org/CVERecord?id=CVE-2021-39131","licence":"CVE Terms of Use","modified":"2024-08-04T01:58:17.881Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-27wq-qx3q-fxm9","url":"https://github.com/advisories/GHSA-27wq-qx3q-fxm9","licence":"CC-BY-4.0","modified":"2026-07-08T06:28:22.894Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-39131","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-39131","licence":"Public domain","modified":"2026-06-17T04:03:07.663Z"}],"updatedAt":"2026-11-25T22:58:03.293Z","epss":{"score":0.01891,"percentile":0.80189,"date":"2026-12-01T12:00:22.000Z"}}