Skip to content

Feature request: configurable safe-directory list via MARKITDOWN_SAFE_DIRS env var #38

Closed

Description

@kdjkdjkdj

Currently get_safe_working_directories() returns a fixed list: Path.cwd(), four home subdirectories (~/Documents, ~/Downloads, ~/Desktop, ~/tmp), the system temp dir, and ./tests/fixtures. Any attempt to access files outside those directories fails with SecurityError: Security violation: invalid path.

This is too restrictive for real-world use. Common cases it blocks:

  • OneDrive / SharePoint / Dropbox sync roots outside the home directory
  • NAS mounts and network drives
  • Project directories on non-system drives
  • Obsidian vaults, repo clones, analysis workspaces outside ~/Documents

There's no CLI flag, config file, or env var to extend the list. Users either give up or fall back to copying files into ~/Documents before every conversion.

Proposal

Read an optional env variable MARKITDOWN_SAFE_DIRS, a platform-appropriate (os.pathsep) separated list of absolute paths. Entries are validated (Path.exists(), then .resolve() for normalization) and appended to the safe-dir list.

# Windows
MARKITDOWN_SAFE_DIRS="D:\OneDrive;D:\Projects"

# Unix
MARKITDOWN_SAFE_DIRS="/mnt/nas:/srv/data"

Non-existent entries are skipped with a logger.warning so typos don't silently disappear.

Security considerations

This widens the sandbox, but:

  1. Only the operator sets the env var — the LLM cannot self-elevate via tool calls.
  2. The existing hardcoded defaults (~/Documents, ~/Downloads, …) already contain arbitrary user files, so the current sandbox is not a meaningful security boundary — it's a convenience default.
  3. Opt-in via env variable is the standard pattern for tools of this shape (NODE_EXTRA_CA_CERTS, PYTHONPATH, PIP_INDEX_URL, etc.).

PR

Implementation follows in a separate PR after #37 lands, to keep the bug fixes and the feature cleanly separated.

Activity

  1. trsdn commented on Jun 10, 2026

    @trsdn
    Owner

    Resolved by the MARKITDOWN_SAFE_DIRS support merged in #44. Thanks again @kdjkdjkdj for the original PR #39 that proposed and validated this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions