CVE-2026-75914: CodeWhale before 0.8.64 Path Traversal via image_analyze symlink
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
imageanalyze follows workspace symlinks and leaks outside-workspace file bytes to the vision endpoint
The imageanalyze tool resolves its imagepath with a bare context.workspace.join instead of routing through ToolContext::resolvepath. 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):
rust async fn execute(&self, input: Value, context: &ToolContext) -> Result<ToolResult, ToolError> { let imagepath = requiredstr(&input, "imagepath")?; let prompt = input .get("prompt") .andthen(|v| v.asstr()) .unwrapor("Describe this image in detail.");
let imagepathbuf = Path::new(imagepath); if imagepathbuf.components().any(|c| { matches!( c, Component::Prefix() | Component::RootDir | Component::ParentDir ) }) { return Err(ToolError::executionfailed( "imagepath must be a relative path within the workspace and cannot escape it.", )); } let resolvedpath = context.workspace.join(imagepathbuf); let (imagedata, mimetype) = Self::readimagefile(&resolvedpath).await?;
readimagefile (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 ${baseurl}/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/imageocr.rs:60-65:
rust let pathstr = requiredstr(&input, "path")?; let imagepath = context.resolvepath(pathstr)?;
resolvepath 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:
rust if candidate.exists() { let canonical = candidate.canonicalize().maperr(...)?; if !canonical.startswith(&workspacecanonical) && !self.istrustedexternalpath(&canonical) { return Err(ToolError::PathEscape { path: canonical }); } ... }
In the same symlink scenario, imageocr, pandocconvert, readfile, applypatch, rlmopen, and fim all return ToolError::PathEscape because the canonical target falls outside the workspace. imageanalyze is the lone caller that skips this check.
The tool declares ToolCapability::ReadOnly and does not override approvalrequirement(). The trait default (crates/tui/src/tools/spec.rs:612-620) resolves ReadOnly to ApprovalRequirement::Auto. The engine then sets approvalrequired = spec.approvalrequirement() != ApprovalRequirement::Auto, which is false for this tool (crates/tui/src/core/engine/turnloop.rs:1159-1184). The model can invoke imageanalyze 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 resolvepath in the first place.
PoC
A standalone Cargo test reproduces the read-through. Save as crates/tui/tests/imageanalyzesymlinkescape.rs:
rust use deepseektui::config::VisionModelConfig; use deepseektui::tools::spec::{ToolContext, ToolSpec}; use deepseektui::vision::tools::ImageAnalyzeTool; use serdejson::json; use std::fs; use tempfile::tempdir;
#[tokio::test] #[cfg(unix)] async fn imageanalyzefollowsworkspacesymlinkoutsideworkspace() { let outer = tempdir().unwrap(); let workspace = outer.path().join("workspace"); let outside = outer.path().join("outside"); fs::createdirall(&workspace).unwrap(); fs::createdirall(&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(), apikey: Some("test".into()), baseurl: 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 readimagefile 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!({"imagepath": "screenshot.png"}), &ctx) .await .expecterr("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 baseurl 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 readfile returns ToolError::PathEscape:
rust #[tokio::test] #[cfg(unix)] async fn readfilerefusesworkspacesymlinkoutsideworkspace() { use deepseektui::tools::file::ReadFileTool; let outer = tempdir().unwrap(); let workspace = outer.path().join("workspace"); let outside = outer.path().join("outside"); fs::createdirall(&workspace).unwrap(); fs::createdirall(&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 .expecterr("expected PathEscape"); assert!(format!("{err:?}").contains("PathEscape")); }
The fix is one line on crates/tui/src/vision/tools.rs:122:
rust - let resolvedpath = context.workspace.join(imagepathbuf); + let resolvedpath = context.resolvepath(imagepath)?;
resolvepath already handles the pre-join lexical checks (so the existing Path::new(imagepath).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 imageurl.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 {"imagepath": "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 resolvepath call rather than a design tradeoff.
Other sources
CodeWhale versions before 0.8.64 contain a path traversal vulnerability in the imageanalyze tool that fails to canonicalize symlinks before reading files. Attackers can create workspace symlinks pointing to external files with image extensions to leak file bytes to the vision endpoint without user approval.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/codewhaleto a version that resolves this vulnerability.Fixed in 0.8.64 - Upgrade
Upgrade
rust/codewhale-tuito a version that resolves this vulnerability.Fixed in 0.8.64 - Upgrade
Upgrade
npm/deepseek-tuito a version that resolves this vulnerability.Fixed in 0.8.41 - Upgrade
Upgrade
CodeWhaleto a version that resolves this vulnerability.Fixed in 0.8.64 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch 26de44a8bd5051f8f944ea60b2c37ae1d2b7d25e - Configuration
Update ImageAnalyzeTool to resolve the supplied image_path via ToolContext::resolve_path (as used by other file-reading tools) so symlinks are canonicalized and rejected when the canonical target is outside the workspace; this replaces the current bare context.workspace.join(image_path_buf) usage.
CodeWhale image_analyze tool (crates/tui/src/vision/tools.rs) resolve image_path using ToolContext::resolve_path instead of context.workspace.join = context.resolve_path(image_path) - Compensating control
If you cannot upgrade immediately, prevent untrusted content from being able to auto-trigger the auto-approved image_analyze tool (e.g., block or gate tool calls originating from prompt-injection sources such as poisoned README, fetched web page, or MCP server output) to stop bytes from being sent to the vision endpoint without user approval.
Event History
Frequently Asked Questions
What access does an attacker need to exploit this issue?
Instances running a CodeWhale version earlier than 0.8.64 are affected when an attacker can create a symlink in a workspace and invoke the image_analyze tool against it. The symlink must target an external file whose name has an image extension.
Does exploitation require user interaction or approval?
No user approval is required once the attacker can use the vulnerable tool and create the workspace symlink. The tool can read bytes from the symlink target and send them to the vision endpoint.
What is the remediation?
Upgrade CodeWhale to version 0.8.64 or later. The provided data does not identify a separate mitigation for environments that cannot upgrade immediately.