Skip to content

Fix #159: Allow browsing home dir when it lives under a blocked path (WSL/root) - #341

Open
zwanski-start wants to merge 1 commit into
AutoForgeAI:masterfrom
zwanski-start:swarm/issue-159-guido
Open

zwanski-start wants to merge 1 commit into
AutoForgeAI:masterfrom
zwanski-start:swarm/issue-159-guido

Conversation

@zwanski-start

Copy link
Copy Markdown

Problem

When AutoForge runs as root (the default user in many WSL distros and containers), Path.home() is /root. /root is in LINUX_BLOCKED in server/routers/filesystem.py. The folder browser opens on the home directory by default, so GET /api/filesystem/list returned 403 "Blocked access to restricted path: /root" and users could not pick or create a project folder.

Fix

is_path_blocked() now always lets users browse their own home directory, even if it sits inside a blocked system path. This covers /root, and also a home nested under a blocked root such as /var/lib/svc. Inside home, only the blocked paths nested in home still apply: the sensitive credential dirs from SENSITIVE_DIRECTORIES (~/.ssh, ~/.aws, ~/.gnupg, ...). Other system paths (/etc, /var, /proc, ...) stay blocked. Project registration (projects.py) and scaffolding (scaffold.py) also call is_path_blocked, so they get the same fix.

Verification

  • New test_filesystem_blocklist.py (6 tests, all passing):
    • home is allowed even when it is listed as a system-blocked path
    • subdirectories of home are allowed
    • ~/.ssh is still blocked
    • other system paths are still blocked
    • a home nested under a blocked path is allowed while the rest of that path stays blocked
    • list_directory() with no path returns the home listing
  • ruff check passes. python test_security.py passes.
  • mypy reports no new errors in filesystem.py. The only errors there are the existing Windows-only ctypes.windll ones.

Assumptions

  • The issue mentions autoforge --workspace, but the CLI has no such flag. The failure comes from the default home listing, which this PR fixes.
  • If the server runs as root, the operator can already reach /root, so letting them browse it in the UI exposes nothing new. Credential subdirectories stay hidden.

Closes #159

🤖 Generated with Claude Code

…der a blocked path

When the server runs as root (common in WSL and containers), Path.home()
is /root, which is in LINUX_BLOCKED. The folder browser defaults to home,
so every new-project attempt hit 'Blocked access to restricted path: /root'
with a 403.

is_path_blocked() now treats the user's own home directory as browsable
even if it sits under a blocked system path; inside home only the
sensitive credential directories (~/.ssh, ~/.aws, ...) remain blocked.
Other system paths stay blocked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Access Restriction Error When Creating New Projects in WSL

1 participant