/

CVE-2026-51570

Severity:

HIGH RISK

(8.1)

Path Traversal (CWE-22) in Agentscope insert_text_file

CVE-2026-51570

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Unauthorized File Access or Modification

Severity:

HIGH RISK

(8.1)

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 modelscope Agentscope's insert_text_file functionality may allow a caller to reference files outside the intended directory. When the function accepts attacker-influenced paths without adequately constraining them, it could enable unauthorized file access or modification.

Affected context

The issue occurs in Agentscope versions 1.0.0 through 1.0.8 when the insert_text_file operation processes a user-controlled or otherwise untrusted file path. Risk depends on whether an attacker can invoke this functionality and on the permissions available to the running process.

Exploit preconditions

  • Attack surface: The insert_text_file file-handling operation
  • Required access: Ability to invoke the operation or influence its file-path argument
  • Trigger point: File insertion when the supplied path is resolved and accessed
  • Why exploitation is possible: Insufficient path canonicalization or directory-boundary enforcement may allow a path to escape the intended storage location

Why this happens

The underlying issue is improper restriction of user-influenced filesystem paths. If path components are accepted without canonicalization and validation against an approved base directory, traversal sequences or equivalent path representations may cause the application to resolve a location outside its intended scope. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

Potential impact

  • An attacker may read files outside the intended directory
  • An attacker could modify or overwrite files accessible to the application
  • Sensitive configuration, credentials, or source code may be exposed
  • Application integrity could be affected through unauthorized file changes
  • Further compromise may be possible if writable files influence execution or deployment behavior

General mitigation guidance

Mitigation generally focuses on treating file paths as untrusted data and enforcing a narrow filesystem boundary.

Common defensive patterns include:

  • Resolve paths canonically before access and verify they remain beneath an approved base directory
  • Prefer opaque file identifiers or controlled allowlists over arbitrary client-supplied paths
  • Reject traversal markers, absolute paths, alternate separators, and unexpected path representations as defense-in-depth controls
  • Use operating-system permissions and least-privilege service accounts to limit accessible files
  • Apply read-only storage and isolated working directories where file modification is not required
  • Avoid returning detailed filesystem errors that disclose sensitive path information

How teams detect issues like this

Organizations can detect path traversal risks through:

  • Static analysis rules for filesystem APIs receiving request, tool, or message-derived path values
  • Code review checks for missing canonicalization and base-directory containment validation
  • Tests covering relative paths, absolute paths, encoded separators, symbolic links, and platform-specific path forms
  • Runtime monitoring for file access outside approved directories
  • Policy enforcement requiring allowlisted file identifiers and least-privilege filesystem permissions
  • Automated security review tools that flag unsanitized path construction and file operations

Sources

SourceLink
gist.github.comgist.github.com/Ro1ME/c6a6857348472db85895b346ba818195

Frequently asked

questions

Exploitability depends on how insert_text_file is exposed. It may be reachable remotely when an application or agent endpoint allows untrusted users to invoke the operation or provide its path argument.

An attacker generally needs access to a calling interface and influence over the file path. The practical impact also depends on the permissions of the Agentscope process.

Resolve the requested path, enforce containment within a designated directory, and prefer allowlisted file identifiers instead of arbitrary paths.

Combine strict path validation with least-privilege filesystem permissions, isolated working directories, security-focused tests, and monitoring for access outside approved locations.

Find out what's already
exploitable in your codebase.