file_write tool accepts a path containing embedded markup/control characters and fails late with a raw OS error instead of rejecting it up front #175
Labels
No labels
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
#176 TDD: file_write tool accepts a path containing embedded markup/control characters and fails late with a raw OS error instead of rejecting it up front
cleveragents/cleveractors-core
#185 fix(agents): reject malformed file_write path arguments before touching the filesystem
cleveragents/cleveractors-core
Reference
cleveragents/cleveractors-core#175
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Metadata
Commit Message:
fix(agents): reject malformed file_write path arguments before touching the filesystemBranch: bugfix/m1-file-write-path-validation
Background and context
ToolAgent._file_write_tool(src/cleveractors/agents/tool.py) only validates thefileargument for emptiness (_validate_file_write_args) and for traversal / absolute-path / home-directory escapes (_validate_file_path_safety). It has no check that the string is actually a well-formed relative path containing only path-legal characters. When an LLM emits afile_writetool call whosefileargument is corrupted (e.g. contaminated with stray markup the model hallucinated or copy-leaked from elsewhere in its context), that garbage string passes both validators untouched and is handed straight toFileAccessCore.write(), which fails deep inside the OS call with an opaque, hard-to-diagnose error.Current behavior
Observed directly in a production run of the example CLI (
python test_app.py test --llm-protocol http --llm-ip <host> --llm-port 8000 --local-store packages --unsafe --prompt "..." --graph 80487-fpu-actor-tools-graph.yaml). The model emitted afile_writetool call with:The
filevalue has an HTML-like fragment (file" <span class="editor-tab" data-tab="file">) prepended to what was clearly meant to beao486_MiSTer/rtl/ao486/fpu/fpu_stackfile.v. This string is non-empty, contains no.., is not absolute, and does not start with~-- so it sails through both_validate_file_write_argsand_validate_file_path_safetyunmodified. The write then fails insideFileAccessCore.write()with:which
_file_write_toolwraps asExecutionError(f"File write failed: {e}")and surfaces to the agent asTool agent ... execution failed: File write failed: [Errno 2] No such file or directory: .... The agent's only recovery signal is a generic[Errno 2]OS error with no indication that the path itself is malformed; in the captured run, the agent responded with "Let me retry with the correct path" and the graph run ended without producing the intended file.Expected behavior
_validate_file_path_safety(or a new, dedicated check called before it) rejects afileargument that is not a syntactically valid relative file path -- in particular, paths containing characters that can never legally appear in a filename on the target filesystem (e.g. control characters,<,>,", and other shell/markup metacharacters not legitimately part of a path) or containing embedded whitespace runs that indicate a corrupted/concatenated string -- and raises a clearExecutionErrordescribing exactly what about the path is invalid, before any filesystem call is attempted. The error message must be specific enough that the calling agent can self-correct (e.g. "file path contains disallowed characters: '<', '"'" rather than a rawOSError/[Errno 2]).Acceptance criteria
file_writecall whosefileargument contains HTML/markup-like fragments (e.g. embedded<...>tags) or other characters illegal in a filename is rejected by_validate_file_path_safety(or an equivalent new validation step) with anExecutionErrorraised beforeFileAccessCore.write()or any other OS call is reached.ExecutionErrormessage names the specific invalid character(s)/pattern found, not just the eventual OS error._validate_file_path_safetycontinue to pass unchanged.Supporting information
ToolAgent._file_write_tool/ToolAgent._validate_file_path_safetyinsrc/cleveractors/agents/tool.py.llm_requests_prematurely_eneded_the_execution.log) from a CleverActors CLI run. The same run also surfaced an unrelated logging-duplication defect, filed separately as #173/#174 -- not part of this ticket.file_readdirectory listing against symlink TOCTOU) and #105 (symlink-safe open) address security hardening of path resolution; this ticket addresses input validation of the literal path string itself, which is a different concern and does not overlap with either.Subtasks
_validate_file_path_safety(or a new_validate_path_charactershelper called from it) that rejects control characters and markup/shell metacharacters illegal in filenames, with a descriptiveExecutionErrormessage.file_write, and any sibling tools such asfile_readthat take afile/path argument) so the fix is not file_write-specific.features/covering a corrupted path with embedded markup, a path with illegal control characters, and confirm valid paths (including ones with spaces/hyphens) are unaffected.nox -s coverage_report.nox(all default sessions), fix any errors.Definition of Done
This issue is complete when:
Type/TestingTDD issue exists, the TDD scenario (tagged@tdd_expected_fail) is merged first, and this issue's Forgejo dependency correctly shows it depends on that TDD issue.Note for triage
This fits Epic #77 ("LLM Agent Runtime Stabilization") as a tool-dispatch input-validation hardening item, alongside its existing children #39 and #63 -- recommend linking it there, but leaving the final call to maintainer triage.
Blocked by #176 (TDD issue-capture test must be written and merged first, per the mandatory Bug Fix TDD Workflow).
CoreRasurae referenced this issue2026-11-30 12:18:16 +00:00