Skip to content

Markdown file preview fails for symlinks targeting folders outside the project root #3400

Description

@rdanhau

Summary

When a Markdown file is located under a symlinked directory whose target is outside the configured project source, clicking the file link in a thread opens the right-side preview area but the file fails to load. The same behavior works when the symlink target remains inside the project root.

In full-access mode, this is unexpected because the agent can access the file through its unrestricted shell, but BB's file-preview API rejects the canonical symlink target.

Versions and environment

  • BB 0.42.0
  • Ubuntu 24.04.4 LTS
  • Linux 6.8.0-139-generic x86_64
  • Node v24.19.0
  • npm 11.17.0
  • Local BB server/host-daemon setup
  • Reproduced with a project using full-access agent execution

Steps to reproduce

  1. Create a temporary project with one directory inside the project and one directory outside it:

    TMP_DIR="$(mktemp -d)"
    
    mkdir -p "$TMP_DIR/project/internal-target"
    mkdir -p "$TMP_DIR/outside-target"
    
    printf '# Inside\n' > "$TMP_DIR/project/internal-target/inside.md"
    printf '# Outside\n' > "$TMP_DIR/outside-target/outside.md"
    
    ln -s internal-target "$TMP_DIR/project/internal-link"
    ln -s ../outside-target "$TMP_DIR/project/outside-link"
  2. Register $TMP_DIR/project as a local BB project.

  3. Using the project ID returned by BB, run:

    bb project content <PROJECT_ID> internal-link/inside.md --json

    This succeeds.

  4. Run:

    bb project content <PROJECT_ID> outside-link/outside.md --json
  5. Alternatively, create a thread in the temporary project and have the agent write or reference outside-link/outside.md, then click the Markdown file link in the thread.

  6. Clean up the temporary project and temporary files after testing.

Expected vs actual

Expected:

  • In full-access mode, BB should allow the file preview to follow a symlink to an outside target, since the agent is explicitly operating without a filesystem sandbox; or
  • BB should clearly explain that preview access is blocked because the symlink resolves outside the project root.

Actual:

Error: HTTP 400: Path
"/tmp/.../project/outside-link/outside.md" escapes read root

The corresponding API response is:

{
  "code": "invalid_path",
  "message": "Path \"/tmp/.../project/outside-link/outside.md\" escapes read root",
  "retryable": false
}

The equivalent file under a symlink whose target remains inside the project loads successfully.

Evidence

The project file-content route passes the configured project path as rootPath and sends the requested file to the host daemon:

The host daemon resolves the requested path with realpath() and rejects it if the resolved target is outside the root:

The behavior was verified against BB 0.42.0 using the minimal temporary-project reproduction above.

What you ruled out

  • Not a general Markdown preview failure: a regular Markdown file previews correctly.
  • Not a symlink failure in general: symlinks targeting directories inside the project root work.
  • Not a missing file: the outside-target file exists and is readable directly from the host.
  • Not an agent write failure: the agent can create or access the file through unrestricted shell execution.
  • Not the user's project structure: the behavior reproduces with a clean temporary project.
  • Related #3238 and #2602 concern skill/command discovery, not file preview.
  • #3395 concerns external links inside Markdown previews, not filesystem symlink resolution.

Suggested priority and effort

Medium priority, low-to-medium effort. External symlinked folders are a common project layout, especially for shared notes, output folders, generated artifacts, and synchronized directories. There is currently no useful UI explanation or workaround beyond copying the file inside the project or changing the project boundary.

The security check should not simply be removed. A possible design is:

  • in full-access mode, allow explicitly trusted project symlink targets outside the project root;
  • retain the current containment behavior for constrained modes such as accept-edits;
  • or allow projects to declare additional trusted filesystem roots;
  • and always show a specific “preview blocked because this symlink resolves outside the project root” error when access is denied.

Privacy note: this report intentionally omits the affected project's name, actual filesystem paths, filenames, project/thread/environment IDs, research content, usernames, hostnames, and personal identifiers. The reproduction uses a synthetic temporary project.

AGENT GENERATED

Activity

  1. added
    ui
    security
    on Sep 10, 2026
  2. bb-slop-cop commented on Sep 10, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied Type: Feature · Priority: Medium · Effort: High; labels: ui, security. No existing classifications were replaced; final Type was read back and verified.

    Trusted main explicitly enforces canonical-path containment for project previews, independently of agent execution permissions (route, containment check). Extending access requires a trust-policy decision; clearer denial messaging is also a product improvement. Medium priority reflects the limited scope and available project-boundary workaround; High effort reflects the access-policy design.

    No reproduction report or PR: the final Type is Feature, so the rule skips those steps. Changing this security boundary is outside simple-fix scope.

    AGENT GENERATED

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

    securityui

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions