-
Notifications
You must be signed in to change notification settings - Fork 778
Closed
Description
While testing dynamic CLI methods in gws, I noticed runtime file-path inputs for --upload and --output are not consistently validated.
In the released version (gws 0.3.4), both flags accept unsafe absolute paths and proceed successfully.
For agent/LLM-driven usage, this creates a potential local file read/write surface.
Environment
gws(affected):0.3.4(./.local/bin/gws)- Verified with local patched build (not released):
./target/debug/gws(0.4.4) - OS: macOS (Apple Silicon)
Repro (before fix)
./.local/bin/gws --version
./.local/bin/gws drive files create --upload /etc/hosts --dry-run
echo "exit=$?"
./.local/bin/gws drive files list --output /tmp/gws-proof.bin --dry-run
echo "exit=$?"Actual behavior
Both commands succeed with exit=0, even when given absolute paths:
--upload /etc/hosts--output /tmp/gws-proof.bin
Expected behavior
Unsafe runtime file paths should fail validation and exit early. The CLI should:
- reject absolute paths
- reject traversal (
..) - prevent canonical/symlink escapes outside the working directory
- apply the same path-safety checks across runtime entry points
Likely root cause
In core runtime flow:
src/main.rsparses dynamic--upload/--outputand passes them throughsrc/executor.rsperforms file reads/writes (tokio::fs::read,tokio::fs::File::create) without centralized ingress validationsrc/mcp_server.rsuses separate bespoke upload validation logic
So validation exists in some places, but is not consistently enforced at runtime ingress.
Suggested fix
Use shared validators in src/validate.rs and apply them consistently:
validate_safe_input_file_path(...)validate_safe_output_file_path(...)
Apply in:
src/main.rs: validate dynamic--upload/--outputbeforeexecute_method(...)src/mcp_server.rs: reuse shared input-file validator for MCPupload
Verification (after local fix)
cargo build
./target/debug/gws drive files create --upload /etc/hosts --dry-run
echo "exit=$?"
./target/debug/gws drive files list --output /tmp/gws-proof.bin --dry-run
echo "exit=$?"Observed after local fix:
--uploadfails validation (exit=1)--outputfails validation (exit=1)- unsafe absolute paths are rejected before execution
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels