fix/security-all
main
This PR fixes 8 security issues across the codebase:
realpath()
file_save_to_disk()
delete_extras_walk()
lstat()
stat()
receive_incremental_check()
receive_files()
receive_str()
receive_data()
file_restore_metadata()
ZSTD_CONTENTSIZE_UNKNOWN
SSL_accept()
SSL_connect()
wrap_fd_with_ssl()
SSL_set1_host()
src/shared/utils.c
src/shared/file.c
src/shared/protocol.c
src/shared/protocol.h
src/shared/compression.c
src/shared/transport_tls.c
src/shared/delta.c
src/server/server.c
tests/integration/test_tls.py
No dependencies set.
The note is not visible to the blocked user.
Security Fixes
This PR fixes 8 security issues across the codebase:
#154: Path traversal prevents writes/deletes outside destination root
realpath()resolution infile_save_to_disk()to prevent symlink-based escapesdelete_extras_walk()to uselstat()instead ofstat()and skip symlinksreceive_incremental_check()andreceive_files()CHECK_BATCH to uselstat()#156: Unbounded wire sizes enable OOM denial of service
receive_str()receive_data()#157: Metadata restoration applies arbitrary mode bits including setuid/setgid
file_restore_metadata()#159: zstd decompression may allocate ZSTD_CONTENTSIZE_UNKNOWN bytes
ZSTD_CONTENTSIZE_UNKNOWN; fall back to conservative (3x compressed) size#160: TLS I/O doesn't handle SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
SSL_accept()/SSL_connect()retry loop inwrap_fd_with_ssl()#161: TLS client lacks hostname verification
SSL_set1_host()call beforeSSL_connect()to enable hostname verification#162: --delete follows symlinks and may delete outside destination tree
delete_extras_walk()to uselstat()and skip symlinks#170: Delta deserialization doesn't validate array counts from network
Files Changed (9 files, +143/-26)
src/shared/utils.c- lstat + skip symlinks in delete_extras_walksrc/shared/file.c- realpath validation in file_save_to_disk, lstat in receive_incremental_checksrc/shared/protocol.c- bounded string/data sizessrc/shared/protocol.h- MAX_STRING_SIZE/MAX_DATA_PAYLOAD_SIZEsrc/shared/compression.c- ZSTD_CONTENTSIZE_UNKNOWN checksrc/shared/transport_tls.c- SSL WANT_READ/WANT_WRITE retry, SSL_set1_host hostname verificationsrc/shared/delta.c- max block/instruction count validationsrc/server/server.c- lstat in CHECK_BATCH pathtests/integration/test_tls.py- IP SAN in test certificatesPull request closed