The vulnerability is a classic path traversal (CWE-22), also known as ZipSlip, within Weaviate's backup and restore functionality. The root cause is the failure to sanitize file paths provided within a backup archive or through file access APIs. An attacker with the ability to create or restore a backup could craft malicious file paths containing '..' sequences or absolute paths.
The analysis of the provided patches pinpoints the exact locations where this sanitization was missing. In commit 89c2270869e6d64f5b5276b8626c11cd816c6665, the backup.unzip.ReadChunk function is fixed. It previously used filepath.Join with a path from the backup archive header (header.Name) without validation. The patch introduces a call to diskio.SanitizeFilePathJoin to prevent directory traversal.
In commit 169df2dc92bc232df62e8fab0a20db2e5371f7aa, the db.Shard.GetFile and db.Shard.GetFileMetadata functions are patched. These functions also constructed file paths using an untrusted relativeFilePath argument. The fix was to add and use a new sanitizeFilePath method on the shard object, which ensures the requested path is confined within the shard's root directory.
During exploitation, a runtime profile would show calls to backup.unzip.ReadChunk when a malicious backup is being restored. Depending on the attack vector, calls to db.Shard.GetFile or db.Shard.GetFileMetadata could also appear in the stack trace if an attacker can control the file path argument passed to these functions during a file retrieval operation related to the backup process.