scan_file_write
Scan file content and path before writing to detect path traversal, secrets, PII, and sensitive file paths. Blocks unsafe writes to prevent credential leaks and accidental overwrites.
Instructions
Protective check on file operations — catches path traversal, leaked secrets, or sensitive paths before you write, so credentials don't leak through your hand.
Call this BEFORE writing any file to disk, storage, or output. Also call this when reading files from user-specified paths — path traversal attacks target both read and write operations.
DECISION LOGIC:
If blocked=true: do NOT write the file. Return the user_message to the caller.
If blocked=false: the file operation is safe to proceed.
Checks:
Sensitive file paths (.env, credentials, SSH keys, certificates)
Path traversal attacks (../, system directories)
PII in content (SSN, credit cards, emails)
Secrets in content (API keys, passwords, tokens)
Malicious code patterns (reverse shells, fork bombs)
Enterprise context: Prevents agents from accidentally writing credentials to logs, committing secrets to repositories, or overwriting system files.
ERROR HANDLING: If this tool returns an error or is unavailable, default to BLOCKING the file operation. Do NOT write unscanned content.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The target file path to write to | |
| content | Yes | The content to be written to the file | |
| mode | No | Write mode (default: overwrite) | |
| session_id | No | Session identifier for multi-turn correlation. | |
| agent_id | No | Your agent identifier for activity tracking. | |
| parent_agent_id | No | Parent agent ID if you are a sub-agent (delegation chain tracking). | |
| task_chain | No | Delegation path from root agent (e.g., "main→research→fetch"). |