Skip to content

GHSA-w7wx-5q49-r59w CVE-2026-75914

CodeWhale: image_analyze follows workspace symlinks, leaking external file bytes

High crates.ionpm
Severity
0.0 / 10
High · CVSS 4.0
Exploit chance (EPSS)
0.53%
Chance of exploitation in the next 30 days. Higher than 44.82% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
CWE-59 Improper Link Resolution Before File Access ('Link Following')
Fix
Available
3 packages have a fixed version

Description

Maintainer resolution

The CodeWhale maintainers validated this report. The affected package ranges are recorded in the advisory metadata. Version 0.8.64 contains the fix in commit 26de44a8bd5051f8f944ea60b2c37ae1d2b7d25e. Users should upgrade to 0.8.64 or later. The original reporter analysis is preserved below.

Summary

image_analyze follows workspace symlinks and leaks outside-workspace file bytes to the vision endpoint

The image_analyze tool resolves its image_path with a bare context.workspace.join instead of routing through ToolContext::resolve_path. The pre-join lexical check rejects absolute paths, Windows prefixes, and parent-dir components but never canonicalizes, so a symlink inside the workspace whose name ends in an image extension and whose target sits outside the workspace is read transparently. The tool has ReadOnly capability and the trait default makes it auto-approved, so the bypass executes with no user prompt.

Details

In crates/tui/src/vision/tools.rs (v0.8.37, lines 104-123):

async fn execute(&self, input: Value, context: &ToolContext) -> Result<ToolResult, ToolError> {
    let image_path = required_str(&input, "image_path")?;
    let prompt = input
        .get("prompt")
        .and_then(|v| v.as_str())
        .unwrap_or("Describe this image in detail.");

    let image_path_buf = Path::new(image_path);
    if image_path_buf.components().any(|c| {
        matches!(
            c,
            Component::Prefix(_) | Component::RootDir | Component::ParentDir
        )
    }) {
        return Err(ToolError::execution_failed(
            "image_path must be a relative path within the workspace and cannot escape it.",
        ));
    }
    let resolved_path = context.workspace.join(image_path_buf);
    let (image_data, mime_type) = Self::read_image_file(&resolved_path).await?;

read_image_file (lines 31-39) is a tokio::fs::read(path) call which follows symlinks. The bytes are then base64-encoded and embedded as data:<mime>;base64,<bytes> in the chat-completion payload that is POSTed to ${base_url}/chat/completions with the user's Authorization header.

The lexical guard rejects ../etc/passwd, /etc/passwd, and C:\Windows\..., but a symlink such as workspace/screenshot.png -> /etc/passwd produces components [Normal("screenshot.png")]. None of Prefix, RootDir, or ParentDir match, so the check passes and the symlink is followed at read time.

The peer file-reading tools all use the central resolver instead. For example, crates/tui/src/tools/image_ocr.rs:60-65:

let path_str = required_str(&input, "path")?;
let image_path = context.resolve_path(path_str)?;

resolve_path in crates/tui/src/tools/spec.rs:342-449 canonicalizes the candidate and rejects results whose canonical form does not start with the canonical workspace path:

if candidate.exists() {
    let canonical = candidate.canonicalize().map_err(...)?;
    if !canonical.starts_with(&workspace_canonical)
        && !self.is_trusted_external_path(&canonical)
    {
        return Err(ToolError::PathEscape { path: canonical });
    }
    ...
}

In the same symlink scenario, image_ocr, pandoc_convert, read_file, apply_patch, rlm_open, and fim all return ToolError::PathEscape because the canonical target falls outside the workspace. image_analyze is the lone caller that skips this check.

The tool declares ToolCapability::ReadOnly and does not override approval_requirement(). The trait default (crates/tui/src/tools/spec.rs:612-620) resolves ReadOnly to ApprovalRequirement::Auto. The engine then sets approval_required = spec.approval_requirement() != ApprovalRequirement::Auto, which is false for this tool (crates/tui/src/core/engine/turn_loop.rs:1159-1184). The model can invoke image_analyze on any turn without a user prompt.

The recent commit 2326220 fix(vision): reject rooted image paths on windows (2026-05-12) tightened the lexical guard to catch Windows drive prefixes, but the original review missed that the underlying problem is that this site never used resolve_path in the first place.

PoC

A standalone Cargo test reproduces the read-through. Save as crates/tui/tests/image_analyze_symlink_escape.rs:

use deepseek_tui::config::VisionModelConfig;
use deepseek_tui::tools::spec::{ToolContext, ToolSpec};
use deepseek_tui::vision::tools::ImageAnalyzeTool;
use serde_json::json;
use std::fs;
use tempfile::tempdir;

#[tokio::test]
#[cfg(unix)]
async fn image_analyze_follows_workspace_symlink_outside_workspace() {
    let outer = tempdir().unwrap();
    let workspace = outer.path().join("workspace");
    let outside = outer.path().join("outside");
    fs::create_dir_all(&workspace).unwrap();
    fs::create_dir_all(&outside).unwrap();

    // A file that the workspace boundary should keep the tool from reading.
    let secret = outside.join("secret.txt");
    fs::write(&secret, b"OUTSIDE-WORKSPACE-SECRET-MARKER").unwrap();

    // Pre-existing symlink in the workspace with an image extension.
    std::os::unix::fs::symlink(&secret, workspace.join("screenshot.png")).unwrap();

    let ctx = ToolContext::new(workspace);
    let tool = ImageAnalyzeTool::new(VisionModelConfig {
        model: "test".into(),
        api_key: Some("test".into()),
        base_url: Some("http://127.0.0.1:1/v1".into()),
    });

    // The execute call will fail at the HTTP layer because the mock endpoint
    // is unreachable, but read_image_file has already been called. Reach the
    // file-read step by asserting that the failure is the HTTP error, not a
    // PathEscape error from the resolver.
    let err = tool
        .execute(json!({"image_path": "screenshot.png"}), &ctx)
        .await
        .expect_err("expected HTTP failure after symlink read");
    let msg = format!("{err:?}");
    assert!(
        !msg.contains("PathEscape"),
        "symlink should have been refused before read; got {msg}"
    );
    // To prove the bytes actually left the process, point base_url at a
    // capturing wiremock instance and assert that the OUTSIDE-WORKSPACE-SECRET-MARKER
    // substring appears in the captured base64-decoded request body.
}

For comparison, the same workspace exercised via read_file returns ToolError::PathEscape:

#[tokio::test]
#[cfg(unix)]
async fn read_file_refuses_workspace_symlink_outside_workspace() {
    use deepseek_tui::tools::file::ReadFileTool;
    let outer = tempdir().unwrap();
    let workspace = outer.path().join("workspace");
    let outside = outer.path().join("outside");
    fs::create_dir_all(&workspace).unwrap();
    fs::create_dir_all(&outside).unwrap();
    fs::write(outside.join("secret.txt"), b"X").unwrap();
    std::os::unix::fs::symlink(outside.join("secret.txt"), workspace.join("link.txt")).unwrap();

    let ctx = ToolContext::new(workspace);
    let err = ReadFileTool
        .execute(json!({"path": "link.txt"}), &ctx)
        .await
        .expect_err("expected PathEscape");
    assert!(format!("{err:?}").contains("PathEscape"));
}

The fix is one line on crates/tui/src/vision/tools.rs:122:

- let resolved_path = context.workspace.join(image_path_buf);
+ let resolved_path = context.resolve_path(image_path)?;

resolve_path already handles the pre-join lexical checks (so the existing Path::new(image_path).components().any(...) block can also be removed), canonicalizes through symlinks, and re-checks workspace containment. The behavior the lexical guard already promises (path stays inside the workspace) is then actually delivered.

Impact

A workspace symlink whose name ends in .png, .jpg, .jpeg, .gif, .webp, or .bmp and whose target sits outside the workspace becomes a read primitive that the model can invoke without an approval prompt. The file bytes are base64-encoded into the image_url.url field of the chat-completion payload and POSTed to the configured vision endpoint along with the user's bearer token. Three exposure channels follow from a single invocation: the vision provider receives every byte of the target file in plaintext (most providers retain request bodies for abuse review or model training), any TLS-terminating corporate proxy on the egress path captures the same bytes, and any transparent middlebox with MITM visibility logs the payload. The preconditions are everyday workspace shapes: cloned repositories that ship symlinks to shared media (CI artifact bundles, photo libraries, design assets), a developer who staged an external file via ln -s, or a git clone with core.symlinks=true against a repository that includes such a link. Because the tool is auto-approved, a prompt-injection delivered through a poisoned README, fetched web page, or MCP server output can issue {"image_path": "screenshot.png"} and the bytes leave the machine on the same turn without any visible UI cue. The fix is identical to the pattern used by every other file-reading tool in this codebase, so the gap is a missed resolve_path call rather than a design tradeoff.

Affected versions

crates.io

PackageVulnerableFixed in
codewhale-tui
>= 0.8.41, < 0.8.64
0.8.64
deepseek-tui
>= 0.8.32, <= 0.8.41
No fix yet

npm

PackageVulnerableFixed in
codewhale
>= 0.8.41, < 0.8.64
0.8.64
deepseek-tui
>= 0.8.32, < 0.8.41
0.8.41

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

codewhale-tui crates.io → 0.8.64

cargo
cargo update -p codewhale-tui --precise 0.8.64

codewhale npm → 0.8.64

npm
npm install codewhale@0.8.64
yarn
yarn add codewhale@0.8.64
pnpm
pnpm add codewhale@0.8.64

deepseek-tui npm → 0.8.41

npm
npm install deepseek-tui@0.8.41
yarn
yarn add deepseek-tui@0.8.41
pnpm
pnpm add deepseek-tui@0.8.41

Severity breakdown

CVSS 4.0 0.0

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N

Attack vector
Network
Attack complexity
Low
Attack requirements
None
Privileges required
None
User interaction
None
Confidentiality (vulnerable system)
High
Integrity (vulnerable system)
None
Availability (vulnerable system)
None
Confidentiality (subsequent systems)
None
Integrity (subsequent systems)
None
Availability (subsequent systems)
None

CVSS 3.1 7.5

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

Weakness

CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.

How to prevent it
  • Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. When validating filenames, use stringent allowlists that limit the character set to be used. If feasible, only allow a single "." character in the filename to avoid weaknesses such as CWE-23, and exclude directory separators such as "/" to avoid CWE-36. Use a list of allowable file extensions, which will help to avoid CWE-434. Do not rely exclusively on a filtering mechanism that removes potentially dangerous characters. This is equivalent to a denylist, which may be incomplete (CWE-184). For example, filtering "/" is insufficient protection if the filesystem also supports the use of "\" as a directory separator. Another possible error could occur when the filtering is applied in a way that still produces dangerous data (CWE-182). For example, if "../" sequences are removed from the ".../...//" string in a sequential fashion, two instances of "../" would b
  • Architecture and Design: For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
  • Implementation: Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked. Use a built-in path canonicalization function (such as realpath() in C) that produces the canonical version of the pathname, which effectively removes ".." sequences and symbolic links (CWE-23, CWE-59). This includes: realpath() in C getCanonicalPath() in Java GetFullPath() in ASP.NET realpath() or abs_path() in Perl realpath() in PHP
  • Architecture and Design: Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
  • Operation: Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
  • Architecture and Design, Operation: Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
  • Architecture and Design: When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs. For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap [REF-185] provide this capability.
  • Architecture and Design, Operation: Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software. OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
  • Architecture and Design, Operation: Store library, include, and utility files outside of the web document root, if possible. Otherwise, store them in a separate directory and use the web server's access control capabilities to prevent attackers from directly requesting them. One common practice is to define a fixed constant in each calling program, then check for the existence of the constant in the library/include file; if the constant does not exist, then the file was directly requested, and it can exit immediately. This significantly reduces the chance of an attacker being able to bypass any protection mechanisms that are in the base program but not in the include files. It will also reduce the attack surface.
  • Implementation: Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success. If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files. Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not. In the context of path traversal, error messages which disclose path information can help attackers craft the appropriate attack strings to move through the file system hierarchy.
  • Operation, Implementation: When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.

CWE-59: Improper Link Resolution Before File Access ('Link Following')

The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.

How to prevent it
  • Architecture and Design: Follow the principle of least privilege when assigning access rights to entities in a software system. Denying access to a file can prevent an attacker from replacing that file with a link to a sensitive file. Ensure good compartmentalization in the system to provide protected areas that can be trusted.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-h539-c7r8-3xq4
CodeWhale: js_execution leaks parent environment to model context via missing env scrub
High Also affects codewhale
GHSA-7j5w-7r7x-9v27
CodeWhale: Argument Injection in `git_show` Tool Allows Arbitrary File Write Without Approval
Critical Also affects codewhale
GHSA-c6mw-8xh8-gpq6
CodeWhale: Argument Injection in `git_blame` Tool Allows Arbitrary File Read Without Approval
High Also affects codewhale
GHSA-gx45-xrj5-g6c4
CodeWhale: Project config `allow_shell` override enables arbitrary shell command execution via cloned repository
High Also affects codewhale
GHSA-62f5-cp2p-vq95
CodeWhale: Project config `instructions` override enables arbitrary file read into AI system prompt via cloned repository
High Also affects codewhale
GHSA-wrj3-vj8c-784f
CodeWhale: rlm_eval auto-approves arbitrary Python execution, bypassing the user's approval policy (RCE)
High Also affects codewhale
GHSA-g29h-pfmp-qp9r
CodeWhale: exec_shell_interact sends LLM-controlled input to a running shell without an approval prompt (privilege escalation)
High Also affects codewhale
GHSA-6v2g-fpxh-pmmh
CodeWhale: SSRF‌ bypass - TOCTOU on DNS failure for DNS pinning
High Also affects codewhale
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor