Skip to content

fix: default project root to workspace instead of user.dir in LocalFilesystemSpec - #2466

Open
waterWang wants to merge 1 commit into
agentscope-ai:mainfrom
waterWang:fix/local-filesystem-default-project
Open

fix: default project root to workspace instead of user.dir in LocalFilesystemSpec#2466
waterWang wants to merge 1 commit into
agentscope-ai:mainfrom
waterWang:fix/local-filesystem-default-project

Conversation

@waterWang

Copy link
Copy Markdown

Fixes #2065

Problem

LocalFilesystemSpec.toFilesystem() falls back to System.getProperty("user.dir") when project is not explicitly set. In non-CLI scenarios (web applications, embedded agents), this exposes the JVM's working directory as the read-only lower layer of the OverlayFilesystem, allowing the agent to read source code, config files, and other sensitive files it should not have access to.

Root cause

Paths.get(System.getProperty("user.dir")) in toFilesystem() — the JVM working directory is unrelated to the agent's intended workspace in non-CLI deployments.

Fix

  • Default effectiveProject to workspace (the agent workspace root, same as the upper layer) instead of System.getProperty("user.dir") when project is null
  • Remove unused import java.nio.file.Paths
  • Update all Javadoc references to reflect the new default

CLI users who need their project directory as the lower layer should continue to call .project(Path) explicitly.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@oss-maintainer oss-maintainer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — PR #2466

fix: default project root to workspace instead of user.dir in LocalFilesystemSpec

Fixes #2065

Summary

Changes the default fallback for LocalFilesystemSpec.toFilesystem() from System.getProperty("user.dir") (JVM working directory) to the agent workspace directory, preventing unintended file system exposure in non-CLI deployments.

Analysis

This is a clean, minimal security fix:

  • Paths.get(System.getProperty("user.dir"))workspace
  • Removes unused import java.nio.file.Paths
  • Updates all Javadoc references to match

The change correctly addresses the root cause: in web applications or embedded agents, the JVM working directory is unrelated to the agent's intended workspace and could expose sensitive files (source code, configs) through the read-only lower layer of OverlayFilesystem.

Observations

  • ✅ Correct security fix — eliminates unintended file system exposure
  • ✅ Minimal diff (4 additions, 5 deletions) — no unnecessary changes
  • ✅ Javadoc updated consistently
  • ✅ CLI users can still use .project(Path) explicitly for the old behavior
  • CI failed — Spotless formatting in LocalFilesystemSpec.java. The diff shows a trailing blank line issue. Run mvn spotless:apply to fix.

Required Action

@waterWang Please run mvn spotless:apply in the agentscope-harness module and push the fix.

Verdict

Request Changes — logic is correct and important security fix, but Spotless formatting must be fixed before merge.

@oss-maintainer

This comment was marked as abuse.

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.

[Bug]:LocalFilesystemSpec falls back to user.dir as project root, leaking JVM working directory to Agent reads

2 participants