Repository navigation
Description
Evidence (origin/main)
reconcile_upload_filename (pkgs/id/crates/id-web/src/routes.rs:1077-1095) returns the caller's multipart filename verbatim whenever its extension already agrees with the validated content type (:1088-1090):
if current.as_deref().is_some_and(|c| acceptable.contains(&c)) {
return name.to_owned();
}Only the mismatch branch canonicalizes (via file_stem, which drops directory components, :1091-1094 — the comment at :1092-1093 even claims upload names are plain file names, but the early return above it does not enforce that).
The upload path then stores that name unchecked:
pkgs/id/crates/id-web/src/routes/file_handlers.rs:453-454— only rejects blank-after-trim filenames, then callsreconcile_upload_filename.file_handlers.rs:388-407(uniquify_upload_name) — returns the intended name verbatim when free or already naming the same blob.file_handlers.rs:551-552—state.store.tags().set(Tag::from(filename), hash)stores it as-is, plus filename-keyed metadata tags below.
FileOps::validate_name (pkgs/id/crates/id-sync/src/fileops.rs:275-296) — documented as "the single canonical-name rule for every FileOps entry point" — rejects exactly these shapes (.. components, rooted names, leading/trailing padding), but the upload path never calls it.
Repro (code-level, verified against the function)
With validated type image/png:
multipart filename |
stored tag name | validate_name says |
|---|---|---|
../../x.png |
../../x.png verbatim |
InvalidName (.. components) |
/abs.png |
/abs.png verbatim |
InvalidName (rooted) |
foo.png (leading space) |
foo.png verbatim |
InvalidName (padding) |
evil.html |
evil.png (mismatch branch, fine) |
ok |
(Any HTTP client can set an arbitrary multipart filename; browsers sending basenames does not constrain the server-side contract.)
Why it matters
- Stored tag names that no forgiving surface can re-specify identically (CLI/REPL trim before calling in): padded twins (
foo.pngvsfoo.png) and path-shaped names (../../x.png,/abs.png) enter the blob-tag and metadata-tag namespaces, defeating the canonical-name invariant every FileOps entry point enforces. - Path-shaped stored names are a latent traversal input for any current or future consumer that joins a tag name onto a filesystem path (export/backup/sync flows).
Sibling cluster (not duplicates)
- id(web): save/new file handlers bypass FileOps canonical name validation #10549 (save/new JSON handlers bypass validation) and id(web): delete/restore file handlers bypass FileOps canonical name validation #10573 (delete/restore JSON handlers bypass validation) cover different handlers with a different fix site. This issue covers the multipart upload path; fix site is
reconcile_upload_filenameinroutes.rs(or avalidate_namegate inupload_handler).
Acceptance criteria
- An upload whose multipart filename carries
..components, a rooted path, or leading/trailing padding is rejected (400) or normalized to the canonical plain file name before any tag/metadata write — no non-canonical name is stored. - The mismatch branch keeps its type-reconciliation behavior (
evil.html+ PNG bytes ->evil.png). - Regression tests pin the verbatim-passthrough cases above (matching extension +
../rooted/padded name) alongside the existingreconcile_upload_filename_matches_validated_typecases.
Activity
developing-today commentedon Nov 16, 2026
CODE-3842