Conversation
Implement the SFTP server subsystem using russh-sftp library for file transfer operations. The handler provides secure file operations with chroot-like path resolution that prevents clients from accessing files outside their designated root directory.
Fix multiple CRITICAL and HIGH security issues in the SFTP server implementation: CRITICAL fixes: - Validate symlink targets in symlink() to prevent path traversal via malicious symlinks - Validate symlink targets in open() and stat() operations before following them - Prevent symlinks from pointing outside the root directory HIGH fixes: - Redact absolute symlink targets in readlink() that point outside root - Prevent ".." directory entry from leaking parent directory metadata outside root - At root boundary, use root's own metadata for ".." instead of actual parent MEDIUM fixes: - Add maximum handle limit (1000) to prevent resource exhaustion - Cap read buffer size to 64KB to prevent memory exhaustion Security improvements: - Extract resolve_path_static() helper for reuse in symlink validation - Use symlink_metadata() instead of metadata() where appropriate - Add comprehensive validation before creating or following symlinks - Improve logging for security-related operations All changes maintain backward compatibility and pass existing tests.
- Add tests for symlink handling in build_longname - Add tests for edge cases: empty paths, special characters, encoded paths - Add tests for all SftpError helper methods and conversions - Add tests for static path resolution method - Add tests for metadata_to_attrs function - Update ARCHITECTURE.md with SFTP handler documentation - Update docs/architecture/README.md with SFTP handler reference - Fix code formatting issues in sftp.rs
Member
Author
PR Finalization ReportProject Structure Discovered
ChecklistTests
Documentation
Code Quality
Changes Made
Verification ResultsReady for final review. |
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.
Summary
russh-sftplibrary for file transfer operationsSftpHandlerstruct implementingrussh_sftp::server::Handlertrait with all SFTP operationssubsystem_requestfor seamless subsystem handlingChanges
New Files
src/server/sftp.rs- Complete SFTP handler implementation with:resolve_path()method with chroot-like path isolationModified Files
src/server/handler.rs- Updatedsubsystem_requestto handle SFTP subsystemsrc/server/mod.rs- Added sftp module exportsrc/server/session.rs- EnhancedChannelStateto storeChannelfor subsystem useSecurity
The SFTP handler implements path traversal prevention by:
..) are clamped to stay within rootTest plan
cargo fmtCloses #132