Repository navigation
Description
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:
LocalFilesystem.resolvePathhands a blank key toapplyNamespacePrefix, which returns it
unchanged, so""resolves tocwd— the workspace root — and the namespace is never
applied.OverlayFilesystemgives 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 recursivegrep/globfrom 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
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): refuse an aliased ancestor of the hidden workspace
fix(harness): refuse an aliased ancestor of the hidden workspace
fix(harness): hold aliased paths to the same boundary as their plain …
fix(harness): keep file enumeration inside the caller's namespace (ag…