CVE-2023-27534: Path Traversal in curl SFTP Tilde Expansion
56008779-01cf-4b8b-9a5e-e7bc611506c5
curl's SFTP implementation contains a path traversal vulnerability (CVE-2023-27534) when handling tilde expansion. When processing SFTP URLs with paths beginning with '//', the Curl_getworkingpath() function expands the tilde to the user's home directory but fails to validate or normalize the remaining path. This allows directory traversal sequences ('/../') to escape the intended home directory boundary. An attacker can craft URLs like 'sftp://user@host//../../etc/passwd' to read arbitrary files on the system outside the user's home directory.",
' (line 64), then expands to home directory (lines 65-79), but at lines 80-82 directly copies the remainder of the untrusted path without validation: memcpy(real_path + homelen, working_path + 3, 1 + working_path_len - 3). This concatenation produces paths that can traverse outside the home directory. Example: '//../../etc/passwd' becomes '/home/user/../../etc/passwd' = '/etc/passwd'. The PoC file sftp_path_traversal_poc.c confirms the exact vulnerability mechanism.",