Skip to content
Heist/ feed
Back to feed
High

Security advisory

Type: advisorySources: OSVCVE: CVE-2021-43854

NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. Versions prior to 3.6.5 are vulnerable to regular expression denial of service (ReDoS) attacks. The vulnerability is present in PunktSentenceTokenizer, sent_tokenize and word_tokenize. Any users of this class, or these two functions, are vulnerable to the ReDoS attack. In short, a specifically crafted long input to any of these vulnerable functions will cause them to take a significant amount of execution time. If your program relies on any of the vulnerable functions for tokenizing unpredictable user input, then we would strongly recommend upgrading to a version of NLTK without the vulnerability. For users unable to upgrade the execution time can be bounded by limiting the maximum length of an input to any of the vulnerable functions. Our recommendation is to implement such a limit.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2021-43854
Confirmed fixed CVEs
Not specified
Updated in this feed
31 Oct 2026, 12:01 UTC · Revision 1

Source evidence

CVE-2021-43854

core-osv · Original source

Published 23 Dec 2021, 18:15 UTC

NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. Versions prior to 3.6.5 are vulnerable to regular expression denial of service (ReDoS) attacks. The vulnerability is present in PunktSentenceTokenizer, sent_tokenize and word_tokenize. Any users of this class, or these two functions, are vulnerable to the ReDoS attack. In short, a specifically crafted long input to any of these vulnerable functions will cause them to take a significant amount of execution time. If your program relies on any of the vulnerable functions for tokenizing unpredictable user input, then we would strongly recommend upgrading to a version of NLTK without the vulnerability. For users unable to upgrade the execution time can be bounded by limiting the maximum length of an input to any of the vulnerable functions. Our recommendation is to implement such a limit.

osv:CVE-2021-43854
Complete source record
{
  "id": "1e3ee1097ddc59b836a9e542f02507234182e67707c14fe98556b7b962ac4e6f",
  "url": "https://osv.dev/vulnerability/CVE-2021-43854",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "CVE-2021-43854",
    "summary": "NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. Versions prior to 3.6.5 are vulnerable to regular expression denial of service (ReDoS) attacks. The vulnerability is present in PunktSentenceTokenizer, sent_tokenize and word_tokenize. Any users of this class, or these two functions, are vulnerable to the ReDoS attack. In short, a specifically crafted long input to any of these vulnerable functions will cause them to take a significant amount of execution time. If your program relies on any of the vulnerable functions for tokenizing unpredictable user input, then we would strongly recommend upgrading to a version of NLTK without the vulnerability. For users unable to upgrade the execution time can be bounded by limiting the maximum length of an input to any of the vulnerable functions. Our recommendation is to implement such a limit.",
    "evidence": "osv:CVE-2021-43854",
    "products": [],
    "severity": "high",
    "structured": {
      "id": "CVE-2021-43854",
      "aliases": [
        "CVE-2021-43854",
        "GHSA-f8m6-h2c7-8h9x",
        "PYSEC-2021-859"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/nltk/nltk",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "b42236425456418b64803f099f6ca1fc3d24031f"
                },
                {
                  "fixed": "1405aad979c6b8080dbbc8e0858f89b2e3690341"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:nltk:nltk:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "3.6.5"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "1405aad979c6b8080dbbc8e0858f89b2e3690341"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "3.6.2",
            "3.6.1",
            "3.6",
            "3.5",
            "3.5b1",
            "3.4.4",
            "3.4.3",
            "3.4.1",
            "3.4",
            "3.3",
            "3.2.5",
            "3.2.4",
            "3.2.3",
            "3.2.2",
            "3.2.1",
            "3.2",
            "3.1",
            "3.0.5",
            "3.0.4",
            "3.0.3",
            "3.0.2",
            "3.0.0b1",
            "3.0a4",
            "2.0.1rc4",
            "2.0.1rc3",
            "2.0.1rc2",
            "2.0.1rc1"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2021-43854.json"
          }
        }
      ],
      "modified": "2026-10-20T10:55:04.548386815Z",
      "provider": "osv",
      "references": [
        "https://github.com/nltk/nltk/commit/1405aad979c6b8080dbbc8e0858f89b2e3690341",
        "https://github.com/nltk/nltk/issues/2866",
        "https://github.com/nltk/nltk/pull/2869",
        "https://github.com/nltk/nltk/security/advisories/GHSA-f8m6-h2c7-8h9x"
      ],
      "provider_metadata": {}
    },
    "related_cves": [
      {
        "value": "CVE-2021-43854",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 386832,
  "published_at": "2021-12-23T18:15:07.327+00:00"
}