feat: tool filter infrastructure, path scoping, and Gen glTFexport#32
Merged
yiwang merged 5 commits intoFeb 17, 2026
Merged
Conversation
ToolFilter/CompiledToolFilter for deny/allow pattern matching on tool inputs, hardcoded deny lists for bash (sudo, pipe-to-shell) and web_fetch (SSRF), path resolution with symlink handling and directory scoping. Also adds allowed_directories to SecurityConfig, per-tool filters to ToolsConfig, and PathDenied audit action.
BashTool now checks commands against compiled deny/allow filters (with hardcoded sudo, pipe-to-shell defaults) before execution. Strict mode errors on protected file references instead of warning. ReadFileTool, WriteFileTool, EditFileTool now resolve symlinks via resolve_real_path(), enforce allowed_directories scoping, and audit PathDenied violations. Filter checks run before existing sandbox and protected-file checks.
WebFetchTool now checks URLs against compiled deny filters before fetching. Hardcoded patterns block localhost, private IPs (10.x, 172.16-31.x, 192.168.x, 127.x), metadata endpoints, file:// and [::1]. User config under [tools.filters.web_fetch] can extend but never remove these defaults via merge_hardcoded().
… main These features already exist on the main branch: - XaiProvider + grok alias + native search trait methods - TavilyProvider + PerplexityProvider + SearchUsageStats - SSRF hardcoded filters (validate_web_fetch_url, is_private_ip) - Hybrid native search passthrough on Anthropic/xAI providers - Web search session tracking + status display Remaining in this branch: tool filter infrastructure, path scoping, bash deny patterns, allowed_directories, PathDenied audit, Gen glTF export.
- Remove blank line between #[cfg] attr and struct (clippy) - Run cargo fmt to fix line wrapping in tests (format) - Add MIT-0 to deny.toml allow list for encase/Bevy deps (license)
yiwang
added a commit
that referenced
this pull request
Feb 17, 2026
validate_web_fetch_url() already provides strictly superior SSRF protection via DNS resolution and IP checking. The regex patterns in hardcoded_filters.rs were a subset of that coverage, added as duplication during the PR #32 revert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ToolFilter/CompiledToolFilter) to core with deny/allow pattern matching, hardcoded defaults that config can extend but never remove, andmerge_hardcoded()deduplicationresolve_real_path,check_path_allowed) with symlink resolution to prevent traversal bypassessecurity.allowed_directorieson all file tools withPathDeniedaudit loggingNote: xAI provider, Tavily/Perplexity search providers, hybrid native search, and SSRF hardcoded filters were removed from this PR as they already exist on main.
What gets blocked (defaults, no config needed)
bashsudo ...,curl | sh,rm -rf /,chmod 777read_fileallowed_directories(if configured)write_fileallowed_directories(if configured)edit_fileallowed_directories(if configured)ln -s /etc/passwd /tmp/xthenread_file /tmp/xresolve_real_path()follows symlinks before checkingConfig extension example
New files
crates/core/src/agent/tool_filters.rsToolFilter/CompiledToolFilter— deny/allow pattern engine (278 lines, 11 tests)crates/core/src/agent/path_utils.rsresolve_real_path,check_path_allowed— symlink-aware path validation (94 lines, 6 tests)crates/core/src/agent/hardcoded_filters.rsTest plan
cargo test --workspace— 152 tests pass (21 new: 11 tool_filters, 6 path_utils, 4 hardcoded_filters)cargo clippy --workspace— no errorscargo build --workspace— cleanallowed_directories = ["/tmp"], attempt file read outside/tmp→ should denycargo run -- ask "what is 2+2"smoke test