Vulnerabilities

41 via 41 paths

Dependencies

10

Source

GitHub

Find, fix and prevent vulnerabilities in your code.

Severity
  • 5
  • 25
  • 10
  • 1
Status
  • 41
  • 0
  • 0

critical severity
new

Deserialization of Untrusted Data

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Deserialization of Untrusted Data through the parse() method in nltk/parse/transitionparser.py. An attacker can execute arbitrary Python code by supplying a malicious parser model file that TransitionParser.parse() loads with pickle_load(f). This affects applications that accept or load untrusted transition parser model paths, letting the payload run with the privileges of the process loading the model.

Details

Serialization is a process of converting an object into a sequence of bytes which can be persisted to a disk or database or can be sent through streams. The reverse process of creating object from sequence of bytes is called deserialization. Serialization is commonly used for communication (sharing objects between multiple hosts) and persistence (store the object state in a file or a database). It is an integral part of popular protocols like Remote Method Invocation (RMI), Java Management Extension (JMX), Java Messaging System (JMS), Action Message Format (AMF), Java Server Faces (JSF) ViewState, etc.

Deserialization of untrusted data (CWE-502) is when the application deserializes untrusted data without sufficiently verifying that the resulting data will be valid, thus allowing the attacker to control the state or the flow of the execution.

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

critical severity
new

Arbitrary Argument Injection

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Arbitrary Argument Injection through the per-call options handling in the java() function in nltk/internals.py. An attacker can achieve arbitrary code execution by supplying crafted java_options containing malicious JVM flags to GenericStanfordParser, StanfordTagger, StanfordTokenizer, or StanfordSegmenter; the options are passed to the Java process without validation, allowing native or Java agents and other code-loading mechanisms to execute. This affects deployments where wrapper options are derived from untrusted user input, configuration, or environment data.

Remediation

Upgrade nltk to version 3.10.3 or higher.

References

critical severity
new

Deserialization of Untrusted Data

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Deserialization of Untrusted Data in nltk.picklesec.AllowlistUnpickler, nltk.tokenize.punkt.punkt_pickle_load, and nltk.parse.transitionparser.TransitionParser.parse. An attacker can execute arbitrary commands by supplying a crafted pickle that uses REDUCE to reach dangerous callables inside an allowlisted namespace, such as numpy.f2py.crackfortran.myeval or nltk.tokenize.repp.ReppTokenizer._execute. This lets a malicious tokenizer or model artifact run code during unpickling, so applications that load untrusted NLTK pickles can be compromised while believing the loader is safe.

Details

Serialization is a process of converting an object into a sequence of bytes which can be persisted to a disk or database or can be sent through streams. The reverse process of creating object from sequence of bytes is called deserialization. Serialization is commonly used for communication (sharing objects between multiple hosts) and persistence (store the object state in a file or a database). It is an integral part of popular protocols like Remote Method Invocation (RMI), Java Management Extension (JMX), Java Messaging System (JMS), Action Message Format (AMF), Java Server Faces (JSF) ViewState, etc.

Deserialization of untrusted data (CWE-502) is when the application deserializes untrusted data without sufficiently verifying that the resulting data will be valid, thus allowing the attacker to control the state or the flow of the execution.

Remediation

Upgrade nltk to version 3.10.3 or higher.

References

critical severity

Server-side Request Forgery (SSRF)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Server-side Request Forgery (SSRF) through the urlopen process in nltk.pathsec. An attacker can reach loopback or internal HTTP services by supplying a hostname that resolves to a public IP during SSRF validation and to a private IP when urllib makes the actual connection. This defeats nltk.pathsec.ENFORCE and lets nltk.download(server_index_url=...) or nltk.data.load("http://...") fetch and return content from services that the filter was meant to block, including internal admin endpoints and metadata services.

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

critical severity

Unsafe Dependency Resolution

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Unsafe Dependency Resolution due to lack of verification or sandboxing in the StanfordSegmenter module, when unvalidated Java Archive (JAR) files are dynamically loaded. An attacker can execute arbitrary Java bytecode by supplying or replacing a JAR file, potentially through model poisoning, Man-in-the-Middle (MITM) attacks, or dependency poisoning.

Remediation

Upgrade nltk to version 3.9.3 or higher.

References

high severity
new

External Control of File Name or Path

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to External Control of File Name or Path through the CorpusReader.__init__ constructor and the LinThesaurusCorpusReader and PanLexLiteCorpusReader implementations in nltk/corpus/reader/api.py, nltk/corpus/reader/lin.py, and nltk/corpus/reader/panlex_lite.py. An attacker can make NLTK read files or open an SQLite database outside the intended nltk.pathsec sandbox by supplying a corpus root path to a reader constructor. The vulnerable constructors turn caller-supplied roots into paths and then reach raw open() or sqlite3.connect() on derived locations without sandbox validation, so a process using these readers can expose out-of-root corpus data. In the affected deployments, this lets untrusted corpus-root input bypass the data-root boundary and load local file contents from outside the intended corpus tree.

Remediation

Upgrade nltk to version 3.10.3 or higher.

References

high severity

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal due to improper sanitization of file paths in the CorpusReader classes. An attacker can gain unauthorized access to sensitive files by supplying crafted file paths to applications that process user-controlled file inputs.

PoC

// PoC.py
from nltk.corpus.reader import WordListCorpusReader, TaggedCorpusReader, BracketParseCorpusReader
from nltk.corpus.reader.util import FileSystemPathPointer

root = FileSystemPathPointer("/")  # unrestricted access to filesystem

# test file - can be any sensitive system file
file_to_read = "etc/passwd"

print("Testing WordListCorpusReader")
reader1 = WordListCorpusReader(root, [file_to_read])
print(reader1.raw(file_to_read)[:200], "\n")

print("Testing TaggedCorpusReader")
reader2 = TaggedCorpusReader(root, [file_to_read])
print(reader2.raw(file_to_read)[:200], "\n")

print("Testing BracketParseCorpusReader")
reader3 = BracketParseCorpusReader(root, [file_to_read])
print(reader3.raw(file_to_read)[:200], "\n")

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.9.3 or higher.

References

high severity

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal via the filestring function. An attacker can access sensitive files by supplying specially crafted input paths, such as absolute paths or directory traversal sequences, to bypass input validation and read arbitrary files on the system.

Note:

This is only exploitable if the function processes untrusted user input, such as in web APIs or network-accessible services.

PoC

from nltk.util import filestring

#Arbitrary file read
content = filestring("/etc/passwd")
print(content)

#Windows Variant
#print(filestring("C:/Windows/System32/drivers/etc/hosts"))

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.9.3 or higher.

References

high severity

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal via the nltk.data.load() function. An attacker can access arbitrary files on the local filesystem by supplying specially crafted URL-encoded path traversal payloads that bypass input validation and are decoded after security checks.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

high severity

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal via the add_root path handling in nltk/corpus/reader/nkjp.py. An attacker can read files outside the corpus root and bypass the nltk.pathsec sandbox by supplying fileids that contain .. sequences, absolute paths, or symlink escapes to the header, raw, words, sents, or tagged_words read methods. The reader concatenates the caller-controlled fileids into filesystem paths and opens them with the builtin open(), so a crafted path can reach an arbitrary header.xml or other target under attacker-chosen directories on the host. In deployments that rely on ENFORCE=True, this exposes local files that were supposed to be blocked by NLTK’s path validation.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

high severity

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal via FramenetCorpusReader.frame() in nltk/corpus/reader/framenet.py. An attacker can read arbitrary XML files by supplying a frame name containing ../ sequences, causing the reader to escape the corpus root and return the parsed file contents. The vulnerable code interpolates the caller-supplied frame name directly into the frame/<name>.xml path and passes that string to XMLCorpusView, bypassing the CorpusReader.open() and nltk.pathsec sandbox checks, including ENFORCE=True. This can disclose out-of-corpus XML data to any application that exposes FrameNet frame lookups to untrusted input.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

high severity
new

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.2.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal via symlink handling in FramenetCorpusReader. An attacker can read arbitrary XML files outside the configured corpus root by placing symlinks with separator-free names inside the corpus directory. These names pass the path validation checks, but resolve to targets outside the intended sandbox when accessed through methods such as frame_by_name(), _lu_file(), or doc().

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.10.2 or higher.

References

high severity
new

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal in StreamBackedCorpusView that bypasses pathsec.ENFORCE by calling builtins.open() directly instead of pathsec.open(). Attackers who control the fileid argument can read arbitrary local files regardless of the ENFORCE setting, including sensitive system files and application credentials.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

high severity
new

Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion')

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion') via the raw xml.etree.ElementTree parsing in nltk.chunk.named_entity.load_ace_file, nltk.internals.ElementWrapper, and nltk.downloader’s XML loaders. An attacker can exhaust memory by supplying a crafted XML document with nested <!ENTITY> declarations that expand a few hundred bytes into megabytes when NLTK parses ACE annotation files, package metadata, or arbitrary XML strings.

Remediation

Upgrade nltk to version 3.10.3 or higher.

References

high severity
new

Insecure Default Initialization of Resource

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Insecure Default Initialization of Resource via disabled security enforcement in pathsec.py. An attacker can bypass protections against path traversal and unsafe pickle deserialization because NLTK defaults ENFORCE to False. In this configuration, failed security validation checks only generate warnings instead of rejecting malicious input, allowing operations that violate the intended security restrictions to continue.

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the FEATURES regex in nltk/corpus/reader/reviews.py. An attacker can hang ReviewsCorpusReader.reviews(), features(), or sents() by supplying a reviews corpus line made of a long run of words with no trailing bracketed feature annotation. The unbounded feature-label pattern backtracks quadratically on such input, burning CPU in the reader and stalling applications that process untrusted or user-supplied review corpora.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

high severity
new

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via regular expression processing in TweetTokenizer.tokenize() and casual_tokenize(). An attacker can cause denial of service by supplying crafted text containing repeated domain-label separators that triggers catastrophic backtracking in the URLS regular expression. Because the affected domain-matching branch can be partitioned in exponentially many ways before ultimately failing, relatively small inputs can consume seconds or minutes of CPU and stall services that tokenize untrusted text.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade nltk to version 3.10.3 or higher.

References

high severity
new

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in TokenSearcher.findall() and Text.findall() in nltk/text.py. An attacker can pin a Python worker and exhaust CPU by supplying a crafted token-regex query, such as a quantified pattern that forces catastrophic backtracking when matched against a long token corpus. Text.findall() delegates directly to TokenSearcher.findall(), which applies the user-controlled expression across the joined corpus string with no execution bound. In applications that expose these search helpers to external input, a single malicious request can stall concordance or token search for other users until the process is interrupted.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

high severity

Eval Injection

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Eval Injection via the __main__ process in collocations.py when command-line arguments are passed directly to the eval function without proper validation or sanitization. An attacker can execute arbitrary Python code, including operating system commands, by supplying crafted command-line arguments.

Remediation

Upgrade nltk to version 3.9.3 or higher.

References

high severity

Improper Verification of Cryptographic Signature

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Improper Verification of Cryptographic Signature via the Stanford Interface Classes. An attacker can execute arbitrary code by supplying a malicious JAR file to the affected Stanford interface classes, which are invoked without integrity verification.

Remediation

There is no fixed version for nltk.

References

high severity
new

Symlink Attack

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.4.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Symlink Attack via symlink handling in CorpusReader.open(). A local attacker can read arbitrary files outside the configured corpus root by placing symbolic links inside the corpus directory that resolve to files outside the intended boundary. Because path validation operates on the lexical path without validating the resolved symlink target, the symlink passes the directory restriction and is subsequently followed during file access.

Remediation

Upgrade nltk to version 3.9.4 or higher.

References

high severity
new

Untrusted Search Path

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Untrusted Search Path through the dot2img function in nltk/parse/dependencygraph.py and the AlignedSent._repr_svg_ method in nltk/translate/api.py. An attacker can execute an arbitrary planted dot binary by supplying a malicious dot on the process search path or in the current working directory when these Graphviz rendering paths invoke dot by bare name. This can lead to arbitrary code execution in the context of the process that renders dependency graphs or SVG output, causing user systems to run attacker-controlled code instead of the intended Graphviz binary.

Remediation

Upgrade nltk to version 3.10.3 or higher.

References

high severity

Remote Code Execution (RCE)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Remote Code Execution (RCE) through the integrated data package download functionality. An attacker with control over the NLTK data index can execute arbitrary code by supplying pickled Python code within untrusted packages and trick a user into loading the malicious pickle.

Some packages found to be vulnerable if compromised are averaged_perceptron_tagger, punkt, maxent_ne_chunker, help/tagsets, and maxent_treebank_pos_tagger.

Remediation

Upgrade nltk to version 3.9 or higher.

References

high severity
new

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal through IPIPANCorpusReader, CrubadanCorpusReader, and LinThesaurusCorpusReader in nltk/corpus/reader/ipipan.py, nltk/corpus/reader/crubadan.py, and nltk/corpus/reader/lin.py. An attacker can disclose files outside a trusted corpus root by placing symlinks inside that root and triggering the readers’ normal corpus-loading methods.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.10.3 or higher.

References

high severity

Missing Authentication for Critical Function

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.4.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Missing Authentication for Critical Function in WordNet Browser HTTP server in default configuration. An attacker can cause the service to terminate immediately by sending a specially crafted unauthenticated HTTP GET request (e.g. http://127.0.0.1:8004/SHUTDOWN%20THE%20SERVER) to the listening port.

Remediation

Upgrade nltk to version 3.9.4 or higher.

References

high severity
new

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) through the _tgrep_node_action() path in nltk/tgrep.py. An attacker can pin a CPU core indefinitely by supplying a tgrep query with a crafted /regex/ node literal that is compiled and searched against tree node labels without a time bound. This affects applications that expose tgrep_positions() or tgrep_compile() to external input, where a single malicious pattern can hang the Python process and block service for other users.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade nltk to version 3.10.3 or higher.

References

high severity

Arbitrary Code Injection

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Arbitrary Code Injection via the _unzip_iter() function due to the lack of validation before unpacking untrusted downloaded packages. An attacker can execute arbitrary code by supplying a specially crafted zip file.

Remediation

Upgrade nltk to version 3.9.3 or higher.

References

high severity
new

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal via the FileSystemPathPointer.open function. An attacker can access arbitrary files accessible to the process user by supplying crafted file:// URLs to the nltk.data.load function.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

high severity

Missing Authentication for Critical Function

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.4.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Missing Authentication for Critical Function via the nltk.app.wordnet_app module. An attacker can cause the server to shut down and disrupt service availability by sending a specially crafted GET request to the WordNet Browser HTTP server when it is running in its default mode.

Remediation

Upgrade nltk to version 3.9.4 or higher.

References

high severity

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.4.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal via the XML index file downloader. An attacker can overwrite arbitrary files and create directories at unintended locations by supplying malicious values for the subdir and id attributes containing path traversal sequences in a remote XML index file.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.9.4 or higher.

References

medium severity
new

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.2.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal via the _get_tag() method in nltk/corpus/reader/ipipan.py, which is the single choke point for channels(), domains(), categories(), and fileids(channels=...). These methods call .replace("morph.xml", "header.xml") on the result of self.abspath(), and because FileSystemPathPointer subclasses str, the .replace() call silently returns a plain string, discarding the PathPointer wrapper. The resulting open() call therefore bypasses nltk.pathsec entirely — including the symlink-resolving, root-scoped containment check used elsewhere in the library. An attacker who can plant a symlink inside the corpus root (with a name containing no path separators or .., so it passes the existing traversal guard) can point it to any file readable by the process, allowing arbitrary local file disclosure.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.10.2 or higher.

References

medium severity
new

Server-side Request Forgery (SSRF)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Server-side Request Forgery (SSRF) via the validate_network_url() DNS resolution path in nltk/pathsec.py. An attacker can make urlopen() reach restricted internal URLs by causing hostname resolution to fail, which leaves the validation loop with no resolved addresses to check and lets the request proceed without rejecting the target. When DNS is unavailable or returns an error for an attacker-supplied hostname, the SSRF filter fails open instead of blocking the request. This can expose internal services such as cloud metadata endpoints to network requests initiated by NLTK and bypass URL validation in applications that rely on it.

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

medium severity
new

Server-side Request Forgery (SSRF)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Server-side Request Forgery (SSRF) via the urlopen process in nltk/pathsec.py. An attacker can reach internal-only HTTP resources by supplying a URL that passes local validation and then fetching it through a configured proxy, which performs the actual egress outside NLTK’s pinning path. This lets an attacker read loopback, link-local, or private network content through callers such as nltk.data.load and downloader fetch paths, causing internal data exposure and allowing the application to retrieve and process forged downloader content.

Remediation

Upgrade nltk to version 3.10.3 or higher.

References

medium severity

Infinite loop

  • Vulnerable module: zipp
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1 tqdm@4.68.2 importlib-metadata@6.7.0 zipp@3.15.0

Overview

Affected versions of this package are vulnerable to Infinite loop where an attacker can cause the application to stop responding by initiating a loop through functions affecting the Path module, such as joinpath, the overloaded division operator, and iterdir.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.

Unlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.

One popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.

When it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.

Two common types of DoS vulnerabilities:

  • High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, commons-fileupload:commons-fileupload.

  • Crash - An attacker sending crafted requests that could cause the system to crash. For Example, npm ws package

Remediation

Upgrade zipp to version 3.19.1 or higher.

References

medium severity
new

Server-side Request Forgery (SSRF)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Server-side Request Forgery (SSRF) via the validate_network_url() address-policy check in nltk/pathsec.py. An attacker can make a strict-mode application send requests to shared-address-space or other non-global hosts by supplying a URL whose resolved IP falls in 100.64.0.0/10, which the filter does not reject. The vulnerable logic only blocked loopback, link-local, multicast, and private addresses, so requests to RFC 6598 carrier-grade NAT targets passed validation. That exposes internal or non-public network resources reachable from the host running NLTK’s network-loading helpers.

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

medium severity
new

Resources Downloaded over Insecure Protocol

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Resources Downloaded over Insecure Protocol via the downloader. An attacker can execute arbitrary code and compromise system integrity by injecting malicious package contents during a man-in-the-middle attack or DNS poisoning, which are then extracted without validation.

Remediation

Upgrade nltk to version 3.9.3 or higher.

References

medium severity
new

External Control of File Name or Path

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.0.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to External Control of File Name or Path via path handling in FramenetCorpusReader and NKJPCorpusReader. An attacker can read and parse arbitrary XML files outside the configured corpus root by supplying crafted selectors or poisoning index state. Attacker-controlled values passed through methods such as frame_by_name(), doc(), lu(), and header() can traverse outside the intended directory and access XML files readable by the application.

Remediation

Upgrade nltk to version 3.10.0 or higher.

References

medium severity
new

Time-of-check Time-of-use (TOCTOU) Race Condition

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Time-of-check Time-of-use (TOCTOU) Race Condition via the downloader process. An attacker can compromise data integrity by causing package archives to be extracted into shared namespaces before integrity validation, which may overwrite trusted resources in machine learning pipelines and environments sensitive to reproducibility. This is only exploitable if a user interacts with the downloader and downloads a malicious package.

Remediation

There is no fixed version for nltk.

References

medium severity

Cross-site Scripting (XSS)

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.4.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via the lookup_... route in the web interface, where attacker-controlled input is reflected into the HTML response without proper escaping. An attacker can execute arbitrary JavaScript in the browser context of the application by convincing a user to open a crafted URL.

Details

Cross-site scripting (or XSS) is a code vulnerability that occurs when an attacker “injects” a malicious script into an otherwise trusted website. The injected script gets downloaded and executed by the end user’s browser when the user interacts with the compromised website.

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

Types of attacks

There are a few methods by which XSS can be manipulated:

Type Origin Description
Stored Server The malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
Reflected Server The attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-based Client The attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
Mutated The attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.

Affected environments

The following environments are susceptible to an XSS attack:

  • Web servers
  • Application servers
  • Web application environments

How to prevent

This section describes the top best practices designed to specifically protect your code:

  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • Give users the option to disable client-side scripts.
  • Redirect invalid requests.
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.

Remediation

Upgrade nltk to version 3.9.4 or higher.

References

medium severity

Uncontrolled Recursion

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.9.4.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Uncontrolled Recursion via the JSONTaggedDecoder.decode_obj() function in jsontags.py. An attacker can cause the application to crash by submitting a deeply nested JSON structure that exceeds the recursion limit, resulting in an unhandled exception.

PoC

import sys, json
from nltk.jsontags import JSONTaggedDecoder

depth = sys.getrecursionlimit() + 50  # e.g. 1050
payload = '{"x":' * depth + "null" + "}" * depth

# Raises RecursionError, crashing the process
json.loads(payload, cls=JSONTaggedDecoder)

Remediation

Upgrade nltk to version 3.9.4 or higher.

References

low severity
new

Directory Traversal

  • Vulnerable module: nltk
  • Introduced through: nltk@3.8.1

Detailed paths

  • Introduced through: h1alexbel/samples-filter@h1alexbel/samples-filter nltk@3.8.1
    Remediation: Upgrade to nltk@3.10.3.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Directory Traversal via multiple corpus readers (crubadan.py, lin.py, xmldocs.py, pl196x.py, mte.py, toolbox.py, named_entity.py, nkjp.py, ipipan.py) that opened files using raw open() or codecs.open() calls, bypassing NLTK's trusted-root containment. An attacker who can place a symlink or hardlink inside a trusted corpus root directory can cause the affected readers to follow the link and read files outside the intended root, disclosing their contents through normal corpus reader methods. Exploitation requires the ability to write a symlink or hardlink into a corpus directory that is subsequently read by the application.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade nltk to version 3.10.3 or higher.

References