Details
Suggested remediation
- Add `instructions` to the `DENY_AT_PROJECT_SCOPE` list at
crates/tui/src/main.rs:5119:
const DENY_AT_PROJECT_SCOPE: &[&str] = &[
"api_key", "base_url", "provider", "mcp_config_path", "instructions"
];
- Alternatively, validate that all instruction paths resolve within the workspace directory:
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())
.filter(|s| {
let resolved = expand_path(s);
resolved.starts_with(workspace) || resolved.is_relative()
})
.collect();
if !entries.is_empty() {
config.instructions = Some(entries);
}
}
- Regression test:
#[test]
fn project_overlay_instructions_rejects_paths_outside_workspace() {
let tmp = workspace_with_project_config(
r#"instructions = ["~/.ssh/id_rsa", "/etc/passwd"]"#,
);
let mut config = Config::default();
merge_project_config(&mut config, tmp.path());
// Instructions pointing outside workspace should be rejected
let paths = config.instructions_paths();
assert!(
paths.iter().all(|p| p.starts_with(tmp.path())),
"instructions paths must be within workspace: {paths:?}"
);
}