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
BlobStore.write_from_path() (storage/blob_store.py:64-103) opens the source file twice:
First open (line 64-73): reads full content to compute SHA-256 hash, records blob_size
Second open (line 85): reads content again to write into blob store
If the source file is modified by another process between the two reads (e.g., a JSONL log being appended to), the hash stored in the filename corresponds to the old content but the bytes stored on disk are the new content. The blob is now corrupted — verify() would detect the mismatch, but only if called explicitly.
Additional issue in write_from_fileobj() (lines 105-153): deduplication check happens after the full temp-file write (line 135), wasting I/O on content that already exists. Also a TOCTOU between dest.parent.mkdir() and os.replace() — a concurrent process could write the same blob and be silently overwritten.
storage/blob_store.py:105-153 — write_from_fileobj() TOCTOU on dedup
Fix direction
write_from_path: compute hash during the first (and only) read pass, buffer or tee the content into the blob store in a single pass
write_from_fileobj: check deduplication before writing to temp file; use O_EXCL or similar to detect concurrent writes
Discovered during adversarial audit 2026-04-26.
Severity note (2026-04-26): This requires the source file to be actively modified by another process during the import window (between the two reads). Most export files are static — JSON dumps, zip archives, or completed log files. The practical risk is lower than initially assessed. Treat as HIGH, not CRITICAL.
Activity
fix: remaining audit findings — content hash, XSS, TOCTOU, detection,…
fix: remaining audit findings — content hash, XSS, TOCTOU, detection,…