Repository navigation
Description
Problem
The web file-management handlers delete_handler and restore_handler (soft-delete / restore) accept req.name and operate on it with only an emptiness check (req.name.trim().is_empty()), then use the original, unvalidated req.name as the tag/metadata key. They never apply the canonical name validation that FileOps enforces for every FileOps entry point (FileOps::validate_name). This lets the web API soft-delete/restore under names that the CLI/REPL/meta protocol reject, diverging behavior across entry points and allowing padded, rooted, ..-containing, or reserved archive-shaped names to enter the tag namespace via the web surface.
This is the delete/restore sibling of the already-tracked save/new gap (#10549); hard_delete_handler delegates to FileOps::delete (which at least emptiness-checks), and rename/copy go through FileOps, but the soft-delete and restore paths bypass FileOps entirely.
Evidence
pkgs/id/crates/id-web/src/routes/file_handlers.rs:1167-1215(delete_handler): rejects only whenreq.name.trim().is_empty()(line ~1173), then looks upstate.store.tags().get(&req.name)and callsstate.tag_store.set_singleton(..., req.name.as_bytes(), b"deleted", ...)using the original untrimmedreq.name— noFileOps::validate_name(or equivalent) check before the side effect.pkgs/id/crates/id-web/src/routes/file_handlers.rs:1218-1262(restore_handler): same emptiness-only check (line ~1224), thenstate.store.tags().get(&req.name)andstate.tag_store.del_by_key(..., req.name.as_bytes(), b"deleted")on the original untrimmed name — no canonical validation.pkgs/id/crates/id-sync/src/fileops.rs:267-296(FileOps::validate_name): documents "The single canonical-name rule for every FileOps entry point" and rejects names that are not exactly trimmed (name != name.trim()), rooted /\-prefixed / Windows drive-prefixed, containing empty/./..path components, or matching the reserved archive-tag shape (is_archive_tag_name->ReservedArchiveName).FileOps::put/rename/copyall validate via this rule.- Contrast:
hard_delete_handler(file_handlers.rs:1268+) delegates toFileOps::delete(fileops.rs:638+), and rename/copy handlers route throughFileOps; only soft delete + restore operate on the raw tag store with the canonical rule absent.
Concrete bypass examples under current code:
- A name with leading/trailing whitespace (e.g.
" notes.md") passes the emptiness check but is used verbatim as the tag key, whileFileOps::validate_namerejects it (not exactly trimmed). - Reserved archive-shaped names (e.g.
doc.md.archive.1234567890, matched byis_archive_tag_name) would be rejected asReservedArchiveNameby FileOps but can receive adeletedtag / have it removed through the web handlers. - Names containing
..components or other shapes forbidden by the canonical rule are not rejected by delete/restore, unlike FileOps-backed paths, and thedeletedtag then lives under a non-canonical key.
Why it matters
- Breaks the "single canonical-name rule for every FileOps entry point" invariant: web soft-deleted/restored files may be keyed under names other surfaces reject, diverging tag/metadata semantics across surfaces.
- The
deletedmarker is stored under the raw, possibly non-canonical name, so a padded or reserved-shaped name can carry (or lose) adeletedtag that FileOps-backed tooling cannot address consistently, reintroducing name/namespace confusion the FileOps validation was meant to prevent (related prior fixes: id(fileops): put stores names verbatim while rename/copy targets are trimmed — padded names create untargetable twin files #4102, id(fileops): archive tag namespace is not reserved — a user file named <name>.archive.<digits> is misclassified as an archive, hard-deleted by delete(<name>), and a put to an existing archive's name silently overwrites it #4720 addressed FileOps-side name/archive rules; id(web): save/new file handlers bypass FileOps canonical name validation #10549 tracks the save/new sibling).
Suggested fix / acceptance criteria
- Apply the canonical name rule to web soft-delete/restore paths: validate
req.nameindelete_handlerandrestore_handlerwithFileOps::validate_name(or the same semantics, after any intended forgiving normalization such as trimming is applied consistently and the stored name is the normalized one) before the existence lookup and before any tag write (set_singleton/del_by_key). - Reject
EmptyName,InvalidName(untrimmed, rooted/drive-prefixed, empty/./..components), andReservedArchiveNamewith clear 4xx responses (and preserve existing behavior for valid names). - Keep behavior consistent with
hard_delete_handler/FileOps paths (same error mapping style) where applicable. - Consider the same validation for other web entry points that accept user-controlled file names outside FileOps (e.g. upload naming, rename/copy request prechecks) for consistency, if not already covered.
- Add regression tests covering: delete and restore reject reserved archive-shaped names; reject names with
../invalid path components; reject untrimmed/whitespace-padded names (or normalize-then-validate consistently); valid ordinary names still soft-delete/restore successfully.
Related
- id(web): save/new file handlers bypass FileOps canonical name validation #10549 (save/new file handlers sibling gap)
- Epic Design: one name, one owner — a file's name is canonical, its archive namespace is reserved, and its archives belong to exactly one file (pkgs/id FileOps) #4766 (canonical name / archive namespace)
Activity
developing-today commentedon Nov 16, 2026
CODE-3835