Skip to content

[Bug]: Blank and relative paths in the file tools enumerate other users' namespaces #4069

Done

Description

@ningmao-hlyz

Summary

With the default local filesystem, a blank or relative path enumerates the whole workspace,
including other users' namespaces:

Call as bob Result
grep_files("alice-secret-memory", "") matches .../alice/MEMORY.md:1:alice-secret-memory — content included
list_files("") lists alice/, bob/
glob_files("**/*.md", "") lists alice/MEMORY.md, alice/outputs/report.md
grep_files("alice-secret-memory", ".") same hits as the blank path

Two independent causes:

  1. LocalFilesystem.resolvePath hands a blank key to applyNamespacePrefix, which returns it
    unchanged, so "" resolves to cwd — the workspace root — and the namespace is never
    applied.
  2. OverlayFilesystem gives the same path to both layers. The lower layer is rooted at the
    project directory, and the default workspace is ${user.dir}/.agentscope/workspace, a
    subtree of it. A recursive grep/glob from the project root therefore walks every
    namespace under the workspace.

The second one also makes the first one reachable through ".", since . is resolved by the
upper layer to the caller's directory and by the lower layer to the project root.

To Reproduce

Path project = Files.createTempDirectory("proj");
Path workspace = project.resolve(".agentscope/workspace");
Files.createDirectories(workspace);

AbstractFilesystem fs =
        new LocalFilesystemSpec()
                .project(project)
                .toFilesystem(workspace, rc -> List.of(rc.getUserId()));

fs.write(RuntimeContext.builder().userId("alice").build(), "MEMORY.md", "alice-secret-memory");

RuntimeContext bob = RuntimeContext.builder().userId("bob").build();
System.out.println(fs.grep(bob, "alice-secret-memory", "", null).matches());
// → a match under .../alice/MEMORY.md, line 1: "alice-secret-memory"

Expected: no matches, and no sibling namespace in the listing.

Actual: alice's memory file is read back to bob.

Why the existing reports do not cover this

#3378 closes the root-equivalent and ..-bearing spellings (./, .., sub/..) on the
enumeration surfaces. A blank key is not among them: it never reaches that helper, and a ..
path does not need it either — the prefix is simply never applied. "." is also different: in
the upper layer it already resolves to the caller's directory, and it only leaks because the
project layer below has no namespace at all and its recursive search walks the workspace
subtree. #3261 / #3292 restrict absolute paths; #3253 is root enumeration under the
UNRESTRICTED default backend of CompositeFilesystem. The shell keeps its own working
directory and is tracked separately in #2329.

Suggested fix

Resolve a blank key as . before the namespace is applied, so an empty path means "the
caller's root" rather than the shared workspace root, and keep the project layer from
enumerating the workspace subtree — skip it while walking, and return nothing when it is
addressed as an explicit search root. Reads and writes through the workspace layer are
unaffected, and deployments without a namespace keep the current behaviour.

Activity

  1. added 13 commits that reference this issue on Nov 8, 2026
    a54c342
    21cb9e3
    0f3b41a
    35e80d5
    7fb5b03
    1cc7342
    dbcd323
    00755d2
    153c448
    b1ddfeb
    fa82037
    d38bd66
    042f0a8
  2. added a commit that references this issue on Dec 2, 2026
    634fe8d
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions