BigPizzaV3/CodexPlusPlus · error
Dream Skin theme path is not a safe directory
Error message
Dream Skin theme path is not a safe directory
What it means
After validating the id, load_stored_dream_skin_theme checks symlink_metadata of state_dir/themes/<id>: the entry must be a real directory and not a symlink. If it is a symlink or a non-directory (file, etc.), it bails with "Dream Skin theme path is not a safe directory" — a hardening check against symlink-based path escapes.
Solutions
- Remove the symlink and place a real directory at themes/<id> (copy the actual content in)
- If using a dotfile manager, exclude the themes directory from symlink management
- Verify with `ls -la` that the entry is a directory (d...) and not a link (l...)
- If a file occupies the path, delete that file and recreate the theme via the library API
Example fix
// before (unsafe state) // themes/my-theme -> /mnt/shared/theme (symlink) // after rm themes/my-theme cp -r /mnt/shared/theme/ themes/my-theme/ # real directory
Defensive patterns
Strategy: validation
Validate before calling
let md = std::fs::symlink_metadata(themes_dir.join(id))?;
if !md.file_type().is_dir() || md.file_type().is_symlink() {
return Err(anyhow::anyhow!("themes/{id} must be a real directory, not a symlink or file"));
} Type guard
fn is_safe_theme_dir(path: &std::path::Path) -> bool {
match std::fs::symlink_metadata(path) {
Ok(md) => md.file_type().is_dir() && !md.file_type().is_symlink(),
Err(_) => false,
}
} Try / catch
match load_stored_dream_skin_theme(&state_dir, &id) {
Ok(draft) => use(draft),
Err(e) if e.to_string().contains("not a safe directory") => eprintln!("themes/{id} is a symlink or not a directory; restore a real directory"),
Err(e) => return Err(e.into()),
} Prevention
- Exclude the themes directory from dotfile managers (stow/chezmoi) that create symlinks
- Prefer copying over symlinking when moving themes between machines
- Periodically audit the themes directory for symlinked entries
When it happens
Trigger: The theme directory under themes/ is a symlink (manually created, restored from a backup tool, or left by malicious tampering), or the path exists but is a regular file rather than a directory.
Common situations: Backup/restore tools that replaced directories with symlinks; a user symlinking themes from another location (e.g. dotfile managers like stow/chezmoi); someone creating a file where the directory should be.
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
- Dream Skin path must not be a symbolic link
- File is a reparse point
- Monitor lock is a reparse point
- 主题包文件名不安全:
- Parent directory is a reparse point
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/e34bc26325350515.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_library.rs:377
let _ = remove_known_theme_directory(&staging);
return Err(error);
}
let stored = load_stored_dream_skin_theme(state_dir, &config.id)?;
Ok(summary_from_draft(&stored, false, false))
}
pub fn load_stored_dream_skin_theme(
state_dir: &Path,
id: &str,
) -> anyhow::Result<DreamSkinThemeDraft> {
if !valid_theme_id(id) {
bail!("invalid Dream Skin theme id");
}
let directory = state_dir.join(THEMES_DIR).join(id);
let metadata = std::fs::symlink_metadata(&directory)
.with_context(|| format!("Dream Skin theme not found: {id}"))?;
if !metadata.file_type().is_dir() || metadata.file_type().is_symlink() {
bail!("Dream Skin theme path is not a safe directory");
}
let config_path = directory.join(THEME_CONFIG_FILE);
let metadata = std::fs::symlink_metadata(&config_path)
.with_context(|| format!("Dream Skin theme config not found: {id}"))?;
if !metadata.file_type().is_file()
|| metadata.file_type().is_symlink()
|| metadata.len() > THEME_CONFIG_LIMIT
{
bail!("invalid Dream Skin theme config");
}
let config: DreamSkinThemeConfig = serde_json::from_slice(&std::fs::read(&config_path)?)?;
if config.id != id {
bail!("Dream Skin theme id does not match directory");
}
let image = find_theme_image(&directory)
.ok_or_else(|| anyhow::anyhow!("Dream Skin theme must contain exactly one image"))?;
let draft = DreamSkinThemeDraft {
config,View on GitHub (pinned to b1ed92e5e4)