openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Feature Request: XDG Base Directory support for host shell access

Open movida-biz opened this issue 5 months ago • 3 comments

The assistant runs in a sandboxed environment without access to standard XDG directories on the host system ($XDG_CONFIG_HOME, $XDG_DATA_HOME, $XDG_STATE_HOME, etc.).

This limits the assistant's ability to:

  • Read/write config files for tools installed on the host
  • Access application data directories
  • Run commands that depend on standard Linux/macOS filesystem conventions

It would be great if the assistant could be granted scoped access to XDG paths (or a configurable subset) so it can interact with the user's actual development environment, not just its own sandbox.

Implementation Plan

Triage Assessment

Valid feature request. The agent sandbox currently restricts access to the process's own filesystem context. XDG Base Directory support would enable the agent to read/write config and data files in standard Linux/macOS locations ($XDG_CONFIG_HOME, $XDG_DATA_HOME, $XDG_STATE_HOME). The existing trusted_roots mechanism in SecurityPolicy (src/openhuman/config/schema/autonomy.rs, src/openhuman/security/policy.rs) already provides a per-user opt-in for additional paths -- this feature would extend it with built-in awareness of XDG directories.

Proposed Scope

  • Add XDG directory resolution to the sandbox path policy.
  • Either auto-include XDG paths when a host shell tool is used, or provide a trusted_roots preset.
  • Respect existing is_workspace_internal_path and is_always_forbidden fail-closed rules.
  • Document the XDG convention in agent prompts.

Implementation Steps

  1. XDG path resolution (src/openhuman/security/policy.rs): add a helper that resolves $XDG_*_HOME environment variables (falling back to ~/.config, ~/.local/share, ~/.local/state per the XDG spec). Return resolved canonical paths.
  2. Trusted roots extension (src/openhuman/config/schema/autonomy.rs): add a auto_xdg_roots: bool field in SecurityPolicy. When true and the origin is interactive (WebChat), automatically include resolved XDG paths in trusted_roots.
  3. Prompt documentation (src/openhuman/agent/prompts/): update the host-shell tool prompt to mention that XDG config/data directories are accessible when the feature is enabled.
  4. Verification: test that XDG paths are resolved correctly and included in the sandbox allowlist.

Verification

  • Unit test: cargo test --lib security::policy -- XDG path resolution.
  • Unit test: tool execute with XDG paths in trusted roots succeeds; without them, blocked.
  • Manual: host shell tool accessing ~/.config/git/config on Linux.

Risks and Open Questions

  • Risk: auto-including XDG paths could grant unintended read access to credentials stored in config directories. Mitigation: default off; user opts in.
  • Platform: XDG is Linux-first. macOS has equivalent conventions but no Base Directory spec. Should this be Linux-only initially?

Acceptance Criteria

  • [ ] XDG config/data/state directories resolved per XDG Base Directory spec.
  • [ ] Configurable auto-inclusion in trusted_roots (default off).
  • [ ] Host shell tool can access paths under resolved XDG directories.
  • [ ] is_always_forbidden paths (system/credential dirs) still blocked.

movida-biz avatar Jun 28 '26 21:06 movida-biz

Verified — still unimplemented on main (6be58a9ab); valid request, and there is a manual workaround today

Not implemented. No XDG resolution exists anywhere in the security layer — grep -rIn "XDG_CONFIG_HOME\|XDG_DATA_HOME\|XDG_STATE_HOME\|auto_xdg" across src/openhuman/security/ and src/openhuman/config/schema/autonomy.rs returns nothing. The only xdg string in the policy tree is unrelated: a note at src/openhuman/security/policy/policy_command_part_01.rs:553 about OS-native launchers (open, xdg-open, start) being deliberately excluded.

The mechanism the triage plan builds on does exist, so the plan's premise is sound. trusted_roots is live on both the config schema and the runtime policy:

// src/openhuman/config/schema/autonomy.rs:62
pub trusted_roots: Vec<TrustedRoot>,

// src/openhuman/security/policy/types.rs:58-64
pub struct TrustedRoot {
    /// Absolute path (a leading `~` is expanded to the user's home).
    pub path: String,
    /// Whether the agent may write within this root.
    #[serde(default)]
    pub access: TrustedAccess,
}

It defaults to empty (autonomy.rs:190, types.rs:419) — opt-in, which matches the plan's stated mitigation.

Workaround available now

Because TrustedRoot.path expands a leading ~, the XDG defaults can be added by hand today without waiting on this issue:

[[autonomy.trusted_roots]]
path = "~/.config"
access = "read"

[[autonomy.trusted_roots]]
path = "~/.local/share"
access = "read"

[[autonomy.trusted_roots]]
path = "~/.local/state"
access = "read"

That covers the spec defaults but not the case where $XDG_CONFIG_HOME etc. are set to non-default locations — which is precisely the gap this issue asks to close, since a static config file cannot read the environment. Worth stating in the issue as the reason the feature is more than a docs task.

Two points from the triage plan worth settling before implementation

  1. The open question in the plan ("Should this be Linux-only initially?") is still open and should be answered first, since it changes the shape of the API. macOS has no XDG Base Directory spec; tools that honour $XDG_CONFIG_HOME on macOS do so by convention, and ~/Library/Application Support is the native equivalent. A flag named for XDG that silently maps to Apple paths would be surprising; one that is a no-op on macOS should say so.
  2. The credential-exposure risk is real and ~/.config is the sharp edge — it routinely holds ~/.config/gh/hosts.yml, ~/.config/gcloud, and similar. Default-off is the right call, but a preset that adds ~/.config wholesale is a meaningfully different grant from one that adds specific subdirectories. Worth deciding whether the preset is the three XDG roots or an allowlist within them.

Leaving open as a valid, unimplemented feature request.

YellowSnnowmann avatar Sep 11 '26 09:09 YellowSnnowmann

Triage: valid — Current review confirms this is a concrete, in-scope engineering issue or request: “Feature Request: XDG Base Directory support for host shell access”. No complete resolution is evident in current main.

senamakel avatar Oct 09 '26 17:10 senamakel

Thanks. Confirmed on current main: there's no automatic access to the XDG directories ($XDG_CONFIG_HOME, $XDG_DATA_HOME, …).

In the meantime you can grant them yourself: Settings → Agent access lets you add a folder (for example ~/.config or a specific app's directory) with read or read+write access, and the agent can then use it. The extra command restrictions are also off by default now.

The request to resolve and offer XDG paths automatically is still open, as a feature.

M3gA-Mind avatar Nov 16 '26 16:11 M3gA-Mind