jdx/mise · error
invalid path inside recovery directory
Error message
invalid path inside recovery directory
What it means
validate_snapshot checks each relative path recorded in the snapshot (dirs, files, links). A relative path is rejected if it is empty, contains any component that is not a plain Normal component (so `..`, `.`, or absolute/root components are disallowed), or duplicates one already seen. This guarantees recovery only ever touches paths strictly inside the recovery directory.
Solutions
- Fix or remove the offending rel entry in the snapshot journal so every path is a non-empty sequence of Normal components and unique
- Re-record the snapshot so the journal is regenerated with normalized relative paths
- Deduplicate entries if the same path was recorded twice
- Reject the input at import time by validating each rel path before accepting it
Example fix
// before
files.push(FileEntry { rel: PathBuf::from("a/../../etc/passwd"), .. });
// after
let rel = path.strip_prefix(&root)?; // ensure it is inside the recovery dir
assert!(rel.components().all(|c| matches!(c, Component::Normal(_))));
files.push(FileEntry { rel: rel.to_path_buf(), .. }); Defensive patterns
Strategy: validation
Validate before calling
use std::path::Component;
fn rel_ok(rel: &std::path::Path) -> bool {
!rel.as_os_str().is_empty()
&& rel.components().all(|c| matches!(c, Component::Normal(_)))
} Prevention
- Derive rel paths with strip_prefix from the snapshot root, never string slicing
- Deduplicate entries before serializing the snapshot
- Validate all rel paths when importing or merging journals
When it happens
Trigger: recover_path on a snapshot whose journal contains an empty rel path, a rel with `..` or `.` components, or the same relative path appearing twice across dirs/files/links entries — typically from hand-edited, imported, or corrupted journal metadata.
Common situations: Journals merged or imported from external sources with path normalization differences; corrupted metadata after a crash; duplicated entries from a bug in the recording tooling; scripts writing raw rel paths without normalization.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- bootstrap_command returned an unsafe mise path
- brew-cask: command_wrapper requires a command name without…
- install_mise must be an absolute path or start with ~/
- install_mise must name an executable file
- install_mise must not contain a newline
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/7245533563c3d2d7.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/history/recovery.rs:169
read_blob(state_dir, content)?;
}
PathSnapshot::Dir {
files, links, dirs, ..
} => {
let mut seen = BTreeSet::new();
for relative in files
.iter()
.map(|f| &f.rel)
.chain(links.iter().map(|f| &f.rel))
.chain(dirs.iter().map(|f| &f.rel))
{
if relative.as_os_str().is_empty()
|| !relative
.components()
.all(|c| matches!(c, Component::Normal(_)))
|| !seen.insert(relative)
{
bail!("invalid path inside recovery directory");
}
}
for leaf in files
.iter()
.map(|f| &f.rel)
.chain(links.iter().map(|f| &f.rel))
{
if seen
.iter()
.any(|other| *other != leaf && other.starts_with(leaf))
{
bail!("recovery directory descends through a file or symlink");
}
}
for file in files {
read_blob(state_dir, &file.content)?;
}
}View on GitHub (pinned to 533346cc37)