Repository navigation
Description
Describe the bug
MarketplaceStager uses an unvalidated skill name to construct its staging directory:
scopeRoot.resolve(ns).resolve(name)
In agentscope-harness/src/main/java/io/agentscope/harness/agent/skill/runtime/MarketplaceStager.java, this directory is subsequently used for resource writes and stale-file cleanup.
The resource-path checks do not fully protect these operations because the staging directory itself may already point outside the cache.
Verified behavior:
- An absolute-path skill name can create or overwrite resource files outside the workspace.
- Stale-file cleanup can delete existing files in that destination.
- A relative traversal name can cause cleanup outside the cache, even when the resource-path check blocks writing.
- The absolute-path case also reproduces when the name is loaded from
SKILL.mdfrontmatter inside an otherwise ordinary repository directory. - Source namespaces participate in the same unchecked path construction.
The affected operations run with the permissions of the JVM process. This finding concerns the Harness skill-staging path; it does not establish unconditional remote code execution or exposure in every agent configuration.
To Reproduce
Use an isolated temporary directory containing two sibling directories, workspace and outside.
- Create
outside/keep.txtcontaining a harmless marker. - Construct an
AgentSkillwhose name is the absolute path tooutside, with a resource map containingmarker.txt. - Associate it with a non-
WorkspaceSkillRepositoryrepository usingnew MarketplaceStager.RepoBound(skill, repository). - Call
new MarketplaceStager(workspace).stage(...)with that entry and a normal source namespace. - Inspect the temporary
outsidedirectory.
Actual result:
outside/marker.txtis written.outside/keep.txtis deleted by stale-resource cleanup.- The staging result reports
StageResult.Cached.
The same behavior can be reproduced by loading the absolute name from SKILL.md through FileSystemSkillRepository.
All verification used harmless files under a temporary test directory.
Expected behavior
Skill names and source namespaces must not redirect staging or cleanup outside their intended cache directories.
Invalid path components should be rejected before any filesystem mutation. The affected entry should receive StageResult.NONE, while valid skills continue staging normally.
Existing supported names that are safe directory components should remain compatible.
Error messages
The absolute-path case does not necessarily throw an exception. The failure is an unexpected filesystem mutation:
outside_write=true
outside_sentinel_removed=true
accepted_as_cached=true
For relative traversal, the observed result was:
outside_write=false
outside_sentinel_removed=true
accepted_as_cached=true
Environment (please complete the following information):
- AgentScope-Java Version: 2.0.4-SNAPSHOT
- Inspected revision: 857e3e6
- Java Version: OpenJDK 21
- OS: Windows 11
Additional context
I have prepared a focused local fix that:
- Normalizes the cache root.
- Validates both skill names and source namespaces as single directory components before materialization or cleanup.
- Handles invalid paths through the existing per-skill failure handling.
- Preserves normal staging, binary resources, and stale-resource cleanup.
- Adds regression tests and updates the English and Chinese skill documentation.
Validation: 31 new regression cases passed; the focused suite completed with 79 tests, zero failures or errors, and one POSIX-only test skipped on Windows. Spotless, Javadoc generation, and documentation validation passed.
Happy to submit a PR for review.
Activity
25344xiaoning commentedon Sep 26, 2026
Submitted PR #3314 to address this issue.
The fix validates skill names and source namespaces before staging or cleanup, with regression tests and updated English/Chinese documentation. Local verification completed with 79 tests, zero failures or errors, and one platform-specific skip.
Ready for review.
oss-maintainer commentedon Sep 26, 2026
Issue Evaluation (automated verification against
main@857e3e6)Category:
bug| Status: Confirmed | Severity: critical (host-side file write + recursive delete outside the workspace via untrusted skill metadata)All claims were reproduced against the unmodified
MarketplaceStagerfrom this tree:MarketplaceStager.java:236—Path stagedDir = scopeRoot.resolve(ns).resolve(name);.nameisskill.getName()andnsfalls back tobound.repo().getSource()(:228-234); neither is validated, andstagedDiris never normalised or re-checked againstscopeRoot:290-294—target.startsWith(stagedDir)only constrains writes relative tostagedDir. WhenstagedDiritself is already outside<workspaceRoot>/.skills-cache/<scope>, the guard is satisfied by construction; for..traversal it does block the write, but nothing boundsstagedDiritselfPath.resolvereturns an absolute argument verbatim, soFiles.createDirectories(stagedDir)(:274) andwriteIfChanged(:305-317) act on the attacker-named directory;maybeMarkExecutable(:320) additionally sets+xon shebang/script-suffix files. Result is reported asStageResult.Cached(:243)removeUnexpected(stagedDir, expected)(:301, body:372-403) walksstagedDirand deletes every regular file not inexpected— with an escapedstagedDirthat is an arbitrary outside directory; relative traversal reproduces the deletion even with writes blocked.touch(stagedDir)(:241) likewise escapesSKILL.mdfrontmatterFileSystemSkillRepository.getAllSkills()returns the frontmatter name verbatim; the git/MySQL/Nacos paths reach the same field. Upstream validation exists but not on this path —SkillManageTool.validateNameandMysqlSkillRepository.validateSkillName(rejects/,\,..) guard only the authoring/DB paths:236expression,nsfromsourceNs/repo.getSource()Notable asymmetry:
scopeis sanitised —scopeSegment()(:189-206) flattens to[A-Za-z0-9._-], checks losslessness and length. The same treatment was simply never applied tons/name, so this is a missing-check regression in one expression, not a design dispute.Blast radius.
HarnessSkillMiddleware.stage()→stageAll()runs host-side before sandbox projection (HarnessAgent.java:2874-2878), so this bypasses the sandbox confinement that skill staging is supposed to provide.ShellPathPolicy.joinCache()then advertises the escaped path as<files-root>to the model. Threat model: a user or CI-added marketplace/git skill repository with craftedSKILL.md— untrusted data, executed with JVM process permissions. The report's caveat ("does not establish unconditional remote code execution in every configuration") is accurate.Existing tests (
MarketplaceStagerOrphanGcTest,MarketplaceStagerExecBitTest,SharedWorkspaceSkillStagingE2ETest) have no absolute-name or traversal coverage, so nothing pins the contract.Agreed fix shape (matches the report): validate
nameandnsas single safe path components before any filesystem mutation — reject absolute paths,./..segments, separators andNUL, and assertscopeRoot.normalize().resolve(ns).resolve(name).normalize().startsWith(scopeRoot.normalize()). Throw inside the existingtryat:237-248so the entry falls into the per-skillStageResult.NONEhandling, keeping valid skills staging as before. Add regression cases for absolute name, relative traversal name, absolute/traversal namespace, and frontmatter-sourced names, plus the same guard forsourceNs.Since you have already prepared a fix with regression tests and doc updates, we will not open a competing PR — please submit yours and we will review it against the checks above. If you would rather have us generate one, reply
/approve.Automated evaluation by github-manager (oss-maintainer). Reply
/approveto have us generate the PR,/revise <notes>to adjust the approach, or/rejectto drop it.ci(harness): cover staging namespace fallbacks and collisions
oss-maintainer commentedon Sep 29, 2026
Proposal window closed — no competing PR will be filed from this proposal window
The 72 h feedback window opened by the evaluation above (
5848613552, posted2026-09-26T18:09:43Z) reached its bound on2026-09-29T18:09:43Z. The thread carries no/approve,/reviseor/rejectdirective from a maintainer or the reporter since that evaluation, so no automated PR will be generated from this window and PR generation is skipped here.The thread did answer the underlying question in another way. Community PR #3314 (
fix(harness): prevent skill staging path traversal, authored by @25344xiaoning, who also reported this issue) targets exactly the seam the evaluation described —MarketplaceStageraccepting a skill name that escapes the staging cache. As of this read #3314 is OPEN, not a draft, unmerged, head65f6b32be6, and its review decision is alreadyAPPROVED.So the implementation path here is owned by a community PR that is waiting on a maintainer to land it. Filing a second PR against the same issue is precisely the collision this window policy exists to prevent, which is why the proposal is stood down rather than escalated.
Nothing in this notice disputes the evaluation: unvalidated skill names reaching the staging path is a real path-traversal defect, and the reported finding stands. The productive thread now is #3314 — merge it, request changes, or close it. If #3314 is closed unmerged and this fix is still wanted, reply on this issue and the question will be re-evaluated against whatever
mainlooks like at that point.Automated feedback-window maintenance by github-manager-bot
fix(harness): prevent skill staging path traversal (agentscope-ai#3314)