You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Enumeration surfaces: relative and ..-bearing paths bypass the namespace anchor (sibling-tenant access) #3378
Follow-up from the #3254 review (non-blocking items), covering the ..-segment escape class on the enumeration surfaces that the shared AbstractFilesystem.denotesRootPath helper does not yet close:
Non-root absolute paths containing .. — ls("/alice/../bob") is forwarded raw; absolute paths bypass the namespace prefix, so the enumeration re-roots outside the caller's namespace.
denotesRootPath classifies but does not normalize, so fixing (1) alone is not enough for (2) — the enumeration surfaces (ls/grep/glob) need to normalize ./.. segments (or reject them) before delegation, consistently across CompositeFilesystem and the backends.
Interface-level null-handling test — CompositeFilesystem.grep forwards null verbatim to the default backend (its documented working-directory form); every in-tree backend honours it via denotesRootPath, but containment depends on each new implementation remembering the convention. A contract test enumerating all AbstractFilesystem implementations would pin it.
Scope note
All of these are pre-existing behaviours, explicitly acknowledged as non-blocking in the #3254 review ("nothing here needs a redesign — the follow-ups can be a separate PR"). #3254's javadoc wording was adjusted in that PR to claim only root-spelling closure; this issue tracks closing the remaining ..-segment class.
Suggested direction
Extend denotesRootPath (or add normalizeEnumerationPath at the AbstractFilesystem level) to resolve ./.. for relative input and to strip/resolve .. segments for absolute non-root input before delegation;
or reject relative/..-bearing enumeration paths with an IllegalArgumentException, mirroring how delete/move already gate on validatePath;
plus the interface-level null contract test from (3).
Category: bug | Status: Partially confirmed (verified against main @ addf82b89, 2.0.4-SNAPSHOT)
We reproduced the reported behaviour with an executable probe (a workspace containing user-1/ and user-2/secret.txt; no repo files were modified). The escape class is real, but the affected configuration and the mechanism differ from the report.
Confirmed
Claim
Evidence
Enumeration surfaces (ls/grep/glob) are unguarded, unlike delete/move
validatePath (AbstractFilesystem.java:178-188) has 8 call sites, all on delete/move/upload (LocalFilesystem.java:530,559-560; CompositeFilesystem.java:465,476-477; RemoteFilesystem.java:597,615-616; BaseSandboxFilesystem.java:427,439-440) — none on the enumeration path
LocalFilesystem.java:689-707: .. → user-1/..; then resolveUnrestricted (:681-687) does cwd.resolve(target).normalize() with no validation
CompositeFilesystem.grep forwards null verbatim to the default backend
CompositeFilesystem.java:280-282; documented contract at AbstractFilesystem.java:98 (null searches the working directory). All in-tree backends currently behave, but nothing pins it — no contract test exists
The #3253 guards cover read/upload only, not enumeration
LocalFilesystemModeTest.java:285-293, 314-325, 328-347, 350-369 all target read/upload; there is no ls/grep/glob traversal case anywhere under agentscope-harness/src/test/java/io/agentscope/harness/agent/filesystem/
Corrections
AbstractFilesystem.denotesRootPath does not exist in this tree. Root classification is inlined per call site: "/".equals(path) / ".".equals(path) at CompositeFilesystem.java:199,280,343 and LocalFilesystem.java:421, plus RemoteFilesystem.normalizePath (:720-723). So "extend denotesRootPath" is not an actionable option; "introduce a shared helper" is.
A namespaced ROOTED LocalFilesystem does not leak.resolveRooted calls AbstractFilesystem.validatePath(effectiveKey) as its first statement (LocalFilesystem.java:633-634), so the cwd.resolve("user-2/..").normalize() path you describe is never reached — probe: [ROOTED] ls('..') threw IllegalArgumentException. The reachable escape is UNRESTRICTED + namespace, which is exactly the default backend of RemoteFilesystemSpec when sharedLocalWorkspace=false (RemoteFilesystemSpec.java:244-247, wired via HarnessAgent.java:2428,2438,2499). The report does not mention that configuration, and it is what makes this worth fixing.
./ and sub/.. are not escapes. Both normalize back inside the namespace (probe: [UNRES] ls('sub/..') → [own.txt], [ROOTED] ls('./') → [own.txt]). Rejecting every "relative / ..-bearing" path as the suggested direction implies would break legitimate relative usage; only .. segments that move the resolved result outside the anchor need handling.
Absolute paths bypassing the namespace prefix is intentional and already pinned, not a defect: see the comment at LocalFilesystem.java:693-700 and the tests rooted_absolutePathNotCorruptedByNamespace (LocalFilesystemModeTest.java:149-163) / rooted_leadingSlashWithNamespace (:250-265). Under UNRESTRICTED any absolute path can enumerate the host — that is the documented escape hatch (workspace/LocalFsMode.java) — so ls("/alice/../bob") is one instance of a by-design property; normalizing .. inside it would not restore containment.
"every in-tree backend honours null via denotesRootPath" — each backend handles null its own way (LocalFilesystem.java:397 → "."; RemoteFilesystem.java:335 with normalizePath:720-723 → "/"; BaseSandboxFilesystem.java:334,381; OverlayFilesystem.java:196-199 / ProjectAwareOverlay.java:224-228 / BakedContextFilesystem.java:77-79 pass it through). Notably the sandbox ls does not honour it: null reaches FilesystemUtils.shellQuote (:101-106) and becomes '', i.e. a degraded failure rather than a working-directory search. The contract test you propose should pin ls as well as grep.
Side observation: in ROOTED a traversal attempt raises IllegalArgumentException (:634), while LocalFilesystem.grep only catches SecurityException (:396-400), so the exception propagates raw through CompositeFilesystem to the tool layer instead of surfacing as a typed tool error. Worth folding into the same cleanup.
Severity: high. Cross-tenant enumeration of sibling namespaces (directory names, and file paths via glob) under the default distributed wiring. Not critical: delete/move stay guarded, and local single-user setups default to ROOTED (LocalFilesystemSpec.java:61), which is already safe. Whether read/write also cross the boundary is a strong inference rather than a measured fact — they share resolvePath, but we did not execute that case.
Fix direction we would propose
Primary: tighten LocalFilesystem.resolveUnrestricted (:681-687) for relative input whose normalized result leaves the anchor, mirroring resolveSandboxed:611-613 in both condition and exception type. One call site covers ls/grep/glob/read/write/edit/upload/download/exists (all go through resolvePath), keeps absolute pass-through intact (changing it would break the contracts pinned in correction 4), and matches the documented UNRESTRICTED semantics "relative paths anchor to rootDir" — a relative .. already contradicts that wording today.
Secondary: add the interface-level contract test you suggest, parameterized over all in-tree AbstractFilesystem implementations, pinning (a) grep(null) / ls(null) search the working directory only and (b) ls/grep/glob with .. stay within the namespace. Candidate cases in LocalFilesystemModeTest: unrestricted_namespaced_lsDotDotCannotEscapeUserNamespace, unrestricted_namespaced_globDotDotCannotEscapeUserNamespace, unrestricted_namespaced_dotSlashAndSubDotDotStayInNamespace; plus RemoteFilesystemSpecTest.defaultBackend_namespaced_lsDotDotDoesNotListSiblingNamespaces to pin the production default end-to-end.
Next step
We are not opening a PR unconditionally here. @aiyili if you plan to send this yourself, say so and we will review it; otherwise tell us which fix location you prefer (mode-level in resolveUnrestricted vs a shared enumeration helper on AbstractFilesystem) and we will turn it into a concrete proposal. We would also narrow the scope note to the UNRESTRICTED + namespace wiring per corrections 2–4.
Hi, this is the follow-up I filed from the #3254 review — taking it myself. Plan: resolve ./.. segments for relative input and ..-bearing absolute paths on the enumeration surfaces (shared helper), plus the interface-level null-handling contract test enumerating all AbstractFilesystem implementations. PR coming shortly.
Activity
docs+log(harness): denotesRootPath 措辞收窄至根拼写 + 根路由构造告警(复审非阻塞项)
oss-maintainer commentedon Oct 1, 2026
Issue Evaluation
Category:
bug| Status: Partially confirmed (verified againstmain@addf82b89,2.0.4-SNAPSHOT)We reproduced the reported behaviour with an executable probe (a workspace containing
user-1/anduser-2/secret.txt; no repo files were modified). The escape class is real, but the affected configuration and the mechanism differ from the report.Confirmed
ls/grep/glob) are unguarded, unlikedelete/movevalidatePath(AbstractFilesystem.java:178-188) has 8 call sites, all on delete/move/upload (LocalFilesystem.java:530,559-560;CompositeFilesystem.java:465,476-477;RemoteFilesystem.java:597,615-616;BaseSandboxFilesystem.java:427,439-440) — none on the enumeration path..escapes a per-user namespacels('..')→[user-1/, user-2/],glob('**','..')→[own.txt, user-2/secret.txt]— sibling namespaces become enumerableapplyNamespacePrefixdoes not touch./..segmentsLocalFilesystem.java:689-707:..→user-1/..; thenresolveUnrestricted(:681-687) doescwd.resolve(target).normalize()with no validationCompositeFilesystem.grepforwardsnullverbatim to the default backendCompositeFilesystem.java:280-282; documented contract atAbstractFilesystem.java:98(nullsearches the working directory). All in-tree backends currently behave, but nothing pins it — no contract test exists#3253guards cover read/upload only, not enumerationLocalFilesystemModeTest.java:285-293, 314-325, 328-347, 350-369all targetread/upload; there is no ls/grep/glob traversal case anywhere underagentscope-harness/src/test/java/io/agentscope/harness/agent/filesystem/Corrections
AbstractFilesystem.denotesRootPathdoes not exist in this tree. Root classification is inlined per call site:"/".equals(path)/".".equals(path)atCompositeFilesystem.java:199,280,343andLocalFilesystem.java:421, plusRemoteFilesystem.normalizePath(:720-723). So "extenddenotesRootPath" is not an actionable option; "introduce a shared helper" is.LocalFilesystemdoes not leak.resolveRootedcallsAbstractFilesystem.validatePath(effectiveKey)as its first statement (LocalFilesystem.java:633-634), so thecwd.resolve("user-2/..").normalize()path you describe is never reached — probe:[ROOTED] ls('..') threw IllegalArgumentException. The reachable escape is UNRESTRICTED + namespace, which is exactly the default backend ofRemoteFilesystemSpecwhensharedLocalWorkspace=false(RemoteFilesystemSpec.java:244-247, wired viaHarnessAgent.java:2428,2438,2499). The report does not mention that configuration, and it is what makes this worth fixing../andsub/..are not escapes. Both normalize back inside the namespace (probe:[UNRES] ls('sub/..')→[own.txt],[ROOTED] ls('./')→[own.txt]). Rejecting every "relative /..-bearing" path as the suggested direction implies would break legitimate relative usage; only..segments that move the resolved result outside the anchor need handling.LocalFilesystem.java:693-700and the testsrooted_absolutePathNotCorruptedByNamespace(LocalFilesystemModeTest.java:149-163) /rooted_leadingSlashWithNamespace(:250-265). Under UNRESTRICTED any absolute path can enumerate the host — that is the documented escape hatch (workspace/LocalFsMode.java) — sols("/alice/../bob")is one instance of a by-design property; normalizing..inside it would not restore containment.nullviadenotesRootPath" — each backend handlesnullits own way (LocalFilesystem.java:397→".";RemoteFilesystem.java:335withnormalizePath:720-723→"/";BaseSandboxFilesystem.java:334,381;OverlayFilesystem.java:196-199/ProjectAwareOverlay.java:224-228/BakedContextFilesystem.java:77-79pass it through). Notably the sandboxlsdoes not honour it:nullreachesFilesystemUtils.shellQuote(:101-106) and becomes'', i.e. a degraded failure rather than a working-directory search. The contract test you propose should pinlsas well asgrep.IllegalArgumentException(:634), whileLocalFilesystem.greponly catchesSecurityException(:396-400), so the exception propagates raw throughCompositeFilesystemto the tool layer instead of surfacing as a typed tool error. Worth folding into the same cleanup.Severity: high. Cross-tenant enumeration of sibling namespaces (directory names, and file paths via
glob) under the default distributed wiring. Not critical:delete/movestay guarded, and local single-user setups default to ROOTED (LocalFilesystemSpec.java:61), which is already safe. Whetherread/writealso cross the boundary is a strong inference rather than a measured fact — they shareresolvePath, but we did not execute that case.Fix direction we would propose
LocalFilesystem.resolveUnrestricted(:681-687) for relative input whose normalized result leaves the anchor, mirroringresolveSandboxed:611-613in both condition and exception type. One call site covers ls/grep/glob/read/write/edit/upload/download/exists (all go throughresolvePath), keeps absolute pass-through intact (changing it would break the contracts pinned in correction 4), and matches the documented UNRESTRICTED semantics "relative paths anchor to rootDir" — a relative..already contradicts that wording today.AbstractFilesystemimplementations, pinning (a)grep(null)/ls(null)search the working directory only and (b)ls/grep/globwith..stay within the namespace. Candidate cases inLocalFilesystemModeTest:unrestricted_namespaced_lsDotDotCannotEscapeUserNamespace,unrestricted_namespaced_globDotDotCannotEscapeUserNamespace,unrestricted_namespaced_dotSlashAndSubDotDotStayInNamespace; plusRemoteFilesystemSpecTest.defaultBackend_namespaced_lsDotDotDoesNotListSiblingNamespacesto pin the production default end-to-end.Next step
We are not opening a PR unconditionally here. @aiyili if you plan to send this yourself, say so and we will review it; otherwise tell us which fix location you prefer (mode-level in
resolveUnrestrictedvs a shared enumeration helper onAbstractFilesystem) and we will turn it into a concrete proposal. We would also narrow the scope note to the UNRESTRICTED + namespace wiring per corrections 2–4.Automated evaluation by github-manager-bot
aiyili commentedon Oct 1, 2026
Hi, this is the follow-up I filed from the #3254 review — taking it myself. Plan: resolve
./..segments for relative input and..-bearing absolute paths on the enumeration surfaces (shared helper), plus the interface-level null-handling contract test enumerating all AbstractFilesystem implementations. PR coming shortly.fix(harness): 枚举面 .. 段落规范化,非根绝对路径不再弹出命名空间锚点(agentscope-ai#3378)
fix(harness): 枚举面 .. 段落规范化,非根绝对路径不再弹出命名空间锚点(agentscope-ai#3378)
fix(harness): 枚举面 .. 段落规范化,非根绝对路径不再弹出命名空间锚点(agentscope-ai#3378)
fix(harness): keep file enumeration inside the caller's namespace
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): keep the workspace subtree invisible to the project layer
fix(harness): 枚举面 .. 段落规范化,非根绝对路径不再弹出命名空间锚点(agentscope-ai#3378)
fix(harness): 枚举面 .. 段落规范化,非根绝对路径不再弹出命名空间锚点(agentscope-ai#3378)
fix(harness): keep the workspace subtree invisible to the project layer
fix(harness): 枚举面 .. 段落规范化,非根绝对路径不再弹出命名空间锚点(agentscope-ai#3378)