{"id":"CVE-2021-39176","aliases":["CVE-2021-39176","GHSA-5rwj-j5m3-3chj"],"related":[],"kind":"vulnerability","state":"published","title":"Missing Release of Memory after Effective Lifetime in detect-character-encoding","summary":"detect-character-encoding is a package for detecting character encoding using ICU. In detect-character-encoding v0.3.0 and earlier, allocated memory is not released. The problem has been patched in detect-character-encoding v0.3.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"detect-character-encoding is a package for detecting character encoding using ICU. In detect-character-encoding v0.3.0 and earlier, allocated memory is not released. The problem has been patched in detect-character-encoding v0.3.1.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nIn detect-character-encoding v0.3.0 and earlier, allocated memory is not released.\n\n### Patches\n\nThe problem has been patched in [detect-character-encoding v0.3.1](https://github.com/sonicdoe/detect-character-encoding/releases/tag/v0.3.1).\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 detect-character-encoding 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, using detect-character-encoding in a program accessible over the internet which becomes unavailable when running out of memory. 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 detectCharacterEncoding = require(\"detect-character-encoding\");\n\nconst app = express();\n\napp.get(\"/\", (req, res) => {\n  detectCharacterEncoding(Buffer.from(\"foo\"));\n\n  res.end();\n});\n\napp.listen(3000);\n```\n\n`hey -n 1000000 http://localhost:3000` ([`hey`](https://github.com/rakyll/hey)) causes the Node.js process to consume more and more memory.\n\n### References\n\n- https://github.com/sonicdoe/detect-character-encoding/commit/d44356927b92e3b13e178071bf6d7c671766f588\n- https://github.com/sonicdoe/detect-character-encoding/pull/6","format":"markdown","source":"ghsa"},{"lang":"es","text":"detect-character-encoding es un paquete para detectar la codificación de caracteres usando ICU. En detect-character-encoding versiones v0.3.0 y anteriores, la memoria asignada no es liberada. El problema ha sido parcheado en detect-character-encoding versión v0.3.1","source":"nvd"}],"published":"2021-08-31T18:05:12.000Z","modified":"2026-07-08T06:28:33.588Z","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:2.0","vector":"AV:N/AC:L/Au:N/C:N/I:N/A:P","score":5,"rating":"MEDIUM"}],"cwes":["CWE-401"],"affected":[{"ranges":[{"version":"< 0.3.1","status":"affected"}],"vendor":"sonicdoe","product":"detect-character-encoding","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.3.1"}],"ecosystem":"npm","package":"detect-character-encoding","purl":"pkg:npm/detect-character-encoding","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.3.1"}],"vendor":"detect-character-encoding_project","product":"detect-character-encoding","cpe":"cpe:2.3:a:detect-character-encoding_project:detect-character-encoding:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/sonicdoe/detect-character-encoding/security/advisories/GHSA-5rwj-j5m3-3chj","tags":["exploit","patch","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sonicdoe/detect-character-encoding/pull/6","tags":["issue-tracking","patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sonicdoe/detect-character-encoding/commit/d44356927b92e3b13e178071bf6d7c671766f588","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sonicdoe/detect-character-encoding/releases/tag/v0.3.1","tags":["third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-39176","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/sonicdoe/detect-character-encoding","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-39176","url":"https://www.cve.org/CVERecord?id=CVE-2021-39176","licence":"CVE Terms of Use","modified":"2024-08-04T01:58:18.257Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5rwj-j5m3-3chj","url":"https://github.com/advisories/GHSA-5rwj-j5m3-3chj","licence":"CC-BY-4.0","modified":"2026-07-08T06:28:33.588Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-39176","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-39176","licence":"Public domain","modified":"2026-06-17T04:03:15.150Z"}],"updatedAt":"2026-11-25T22:58:03.586Z","epss":{"score":0.01891,"percentile":0.80177,"date":"2026-12-01T12:00:22.000Z"}}