Repository navigation
Description
Durable spec: https://github.com/emulebb/emulebb-tooling/blob/main/docs/products/emulebb-rust/history/items/RUST-BUG-136.md
RUST-BUG-136 - Bound transfer deletion marker validation reads
Summary
Validate transfer-directory deletion markers with a fixed-size read matching the
16-byte UUID payload, plus one overflow sentinel, instead of reading an
arbitrary regular file to end before authorizing deletion.
Current State
Transfer deletion creates a no-follow regular marker and writes
Uuid::as_bytes(), exactly 16 bytes. Authority validation later reopens the
marker without following links. Validation now limits reads on that same opened
regular-file handle to 17 bytes and copies into a fixed stack buffer. It requires
exactly 16 matching UUID bytes; the extra byte detects oversized content without
allocating according to marker size. Stable directory identity and existing
failure diagnostics remain unchanged.
Why This Matters
Deletion authorization should fail closed with constant resource use. A
corrupted marker must not create a local memory-exhaustion path during startup,
maintenance, or a user-requested transfer deletion, especially in code whose
purpose is to defend destructive filesystem operations.
Representative Sites
crates/emulebb-ed2k/src/ed2k_transfer/metadata.rs
transfer marker creation.crates/emulebb-ed2k/src/ed2k_transfer/metadata.rs
validate_transfer_directory_authority.- No-follow regular-file opening in
ed2k_transfer::ingest.
Intended Shape
- Read exactly the expected 16 bytes and attempt one additional byte to detect
oversize content without allocating from file metadata. - Reject missing, short, long, replaced, non-regular, or unreadable markers as
invalid authority. - Keep validation on the opened no-follow file handle and preserve the existing
stable-directory identity check. - Use a small fixed array or bounded stack buffer rather than a heap vector.
Scope Constraints
- Do not weaken the directory identity or no-follow protections added by
RUST-BUG-122. - Do not authorize deletion based only on marker filename or length.
- UUID bytes are an ownership marker, not a secret; constant-time comparison is
unnecessary. - Existing incompatible/corrupt marker state should fail closed rather than be
migrated during beta.
Acceptance Criteria
- Marker validation performs a constant-memory read bounded to 17 bytes.
- Exactly 16 matching UUID bytes authorize the marker check.
- Missing, short, oversized, mismatched, symlinked, and non-regular markers
all reject deletion. - Directory identity is checked in addition to marker content.
- Startup and maintenance retry paths surface or retain failed deletion
intent without deleting an unauthorised path.
Validation
- Regression tests for exact, empty, short, oversized, and very large marker
files. - Existing symlink/reparse-point and directory replacement adversity tests.
- Restart and maintenance retry coverage for rejected deletion intents.
Implementation Checkpoint
The bounded read changes no schema, marker format, dependencies, or recovery
policy; metadata remains at schema 69. Added runtime regression coverage checks
empty, 15-byte, mismatched 16-byte, 17-byte, 32-byte, and 64 MiB markers in both
the original transfer directory and its deletion tombstone. Each case restarts
the runtime and repeats recovery, requiring the directory identity, internal
payload, marker, and pending deletion intent to survive rejection. Restoring the
exact 16-byte UUID must then permit cleanup and finalization. Existing missing
marker and changed directory identity tests remain in place.
Delivered by PR #335, merged
on 2026-11-15 at Rust 0840e9005fd2ab28e9cbe262054dd692262e5698.
The final pre-merge source c6b9ceff0590b222fe5c5cc23df8622c229809d1
passed the full Windows, Linux and Android local gate and all hosted checks.
The local report is retained under
EMULEBB_WORKSPACE_OUTPUT_ROOT/reports/local-check/emulebb-rust/20261115T075009Z-41880a82.
Android local checks compile and link both ABIs; they do not establish Android
runtime execution. Native hosted jobs execute their applicable runtime tests.
Issue #162 is closed and its Project #3 placement is Done.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
itlezy commentedon Nov 15, 2026
The bounded deletion-marker repair is now allocated on
fix/bounded-deletion-marker, based on actual Rust main23e685b8. Source reconciliation confirms the validator still reads the complete marker into an unrestricted Vec after opening its no-follow regular-file handle.Acceptance is a fixed 17-byte read budget for an exact 16-byte UUID match, using the same opened handle and preserving directory identity, authority and rejection behavior. Exact, short, wrong, oversized and very large marker cases must retain the existing destructive-cleanup safety checks. This changes no schema, dependencies or migration behavior; current schema remains 69.
The worker may prepare code and normal hook-checked checkpoints in parallel. Rust execution remains pending the current full-validation owner. Phase and priority remain unchanged; no runtime pass is claimed.