Severity:

HIGH RISK

(7.3)

Path Traversal in kaggle-mcp prepare_kaggle_dataset Endpoint

CVE-2026-7149

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File System Access Within Server Context

Severity:

HIGH RISK

(7.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in dexhunter's kaggle-mcp project allows crafted competition_id input to influence filesystem paths used by prepare_kaggle_dataset in src/kaggle_mcp/server.py.

When exposed remotely, this can enable attackers to read or manipulate files outside the intended directory scope on the server hosting kaggle-mcp.

Affected context

The issue appears in the server-side logic that prepares Kaggle datasets based on a competition_id argument.

It is relevant when:

  • The kaggle-mcp service is reachable over a network (e.g., as an API or backend service)
  • User-controlled input is passed as competition_id and used to construct filesystem paths
  • There are no robust checks that restrict paths to a specific base directory

Deployments using rolling releases may all be affected until the underlying path handling logic is corrected.

Exploit preconditions

  • Attack surface: Remote interface to the kaggle-mcp service exposing functionality that calls prepare_kaggle_dataset.
  • Required access: Ability to send requests containing a controlled competition_id parameter (e.g., API client, web form, or tool integration).
  • Trigger point: Invocation of prepare_kaggle_dataset where competition_id is used in path construction or file operations.
  • Why exploitation is possible: The competition_id value is used without adequate normalization and enforcement against directory traversal sequences, allowing traversal outside the intended dataset directory.

Why this happens

The vulnerability arises from constructing filesystem paths from user-controlled input without enforcing strict directory boundaries.

Specifically, competition_id is likely concatenated or interpolated into path strings that are later used in file operations (such as open, list, or delete) without normalization and validation.

This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where attackers can introduce sequences like ../ or equivalent encodings to escape the intended root directory and target arbitrary locations accessible to the service process.

Potential impact

  • Reading files outside the intended dataset directory that are accessible to the application process
  • Accessing configuration files, logs, or other sensitive data within the application's filesystem scope
  • Overwriting or deleting files in directories reachable by the effective user, potentially corrupting datasets or application state
  • Gaining additional leverage for other attacks (e.g., information disclosure that aids credential theft or lateral movement)

General mitigation guidance

Effective mitigation focuses on constraining filesystem access and treating all external identifiers as untrusted input:

  • Resolve all file operations relative to a fixed, canonical base directory and reject paths that escape this boundary after normalization.
  • Use high-level path utility functions that join and normalize paths, combined with checks ensuring the final path starts with the expected base directory.
  • Implement strict allowlists for acceptable competition_id values (e.g., only alphanumeric plus known safe separators; reject any path separator characters or traversal patterns).
  • Separate identifiers from actual filesystem structure, for example by mapping competition_id to internally managed directory names or IDs instead of using it directly as a path segment.
  • Run the service with least-privilege filesystem permissions so that even if a traversal occurs, accessible data and writable locations are minimized.

How teams detect issues like this

Organizations can pursue several detection approaches:

  • Static analysis: Scan for pattern of concatenating request parameters or unvalidated input into filesystem paths, especially uses of os.path.join, raw string concatenation, or similar APIs that touch the file system.
  • Code review: Flag any functions where user-supplied identifiers are used directly in path construction; reviewers should look for missing normalization and base-directory checks.
  • Security testing: Implement automated tests and dynamic scanners that attempt directory traversal strings (e.g., ../) against endpoints dealing with file access to confirm that such input is rejected.
  • Policy enforcement: Establish guidelines that require path access helpers and centralized validation routines, and ensure that new code using file operations must rely on these vetted utilities.

Sources

SourceLink
github.comgithub.com/dexhunter/kaggle-mcp/
github.comgithub.com/dexhunter/kaggle-mcp/issues/1
vuldb.comvuldb.com/submit/802052
vuldb.comvuldb.com/vuln/359748
vuldb.comvuldb.com/vuln/359748/cti

Frequently asked

questions

Yes. As described, the vulnerable function can be triggered remotely if the kaggle-mcp service exposes an API or interface that passes user-controlled competition_id values to prepare_kaggle_dataset.

The attacker needs the ability to send requests to the affected service endpoint. No local shell access is required; network-level access to the relevant API is sufficient if authentication or authorization controls do not block the request.

Enforce strict path handling: always resolve paths relative to a predefined base directory, normalize them, and verify that the result cannot escape that directory. Combine this with tight input validation or allowlisting of acceptable competition_id formats.

Treat all external identifiers as untrusted, avoid using raw user input directly in filesystem paths, and centralize path construction behind well-reviewed helper functions. Incorporate static analysis and security-focused code review to catch unsafe path handling early in development.

Find out what's already
exploitable in your codebase.