You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Implement SFTP server handler with path traversal prevention (#132) (#151)
* feat: Implement SFTP server handler with path traversal prevention
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: Address critical security vulnerabilities in SFTP server
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.
* test: Add comprehensive SFTP handler test coverage
- 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
Copy file name to clipboardExpand all lines: docs/architecture/README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,7 @@ bssh is a high-performance parallel SSH command execution tool with SSH-compatib
36
36
-**Server CLI (`bssh-server`)** - Server management commands including host key generation, password hashing, config validation (see main ARCHITECTURE.md)
37
37
-**SSH Server Module** - SSH server implementation using russh (see main ARCHITECTURE.md)
38
38
-**Server Authentication** - Authentication providers including public key verification (see main ARCHITECTURE.md)
39
+
-**SFTP Handler** - SFTP subsystem with path traversal prevention and chroot-like isolation (see main ARCHITECTURE.md)
0 commit comments