Skip to content

Small robustness findings from an audit pass: export names on Windows, staging-name collisions, damaged-log copies, token origin, thumbnail decode limits, …  #2140

Closed

Description

@PierrunoYT

Assessment

Severity: Low / Info each, grouped to keep the tracker tidy. Confidence: Confirmed by code trace unless noted.

Source evidence

  1. Export file names keep characters Windows forbids — crates/engine/src/export.rs:1206 replaces only / \ : \0; a {title} like What?, "Best", control characters or CON / NUL fails with ERROR_INVALID_NAME. Reuse rename::sanitize (rename.rs:54) plus a reserved-name suffix. (No traversal.)
  2. FsStore fixed staging name — crates/catalog/src/store.rs:100, 116 use {name}.tmp; when locking is unsupported (SMB/NFS, library opens with a warning) two writers share it and can publish a torn snapshot. Use .{name}.{pid}.{n}.tmp with create_new, like safe_file::create_temp.
  3. Damaged-log copy can be overwritten — crates/catalog/src/journal.rs:427 names it catalog.log.damaged-<seq> and writes with write_atomic; a second damage at the same seq replaces the only copy. Add a counter or use write_new_unique.
  4. Bearer token origin ignores the port — crates/fetch/src/lib.rs:279-281 compares only url.host; a redirect to https://samehost:8443/ still receives the token. Compare (host, port).
  5. SAM tokenizer files unpinned, mirrors may be http — crates/segment/src/fetch/mod.rs:20-21 (sha256: None, TODO); mirrors from LIGHTCRAFT_SAM3_MIRRORS / the mirrors file may be http://. Pin them or refuse non-https mirrors for unpinned files.
  6. Thumbnail cache decode has no limits or panic guard — crates/preview/src/disk.rs:432 calls zune-jpeg directly (default ~16 k² max, no catch_unwind, unlike lightcraft_codecs::decode); planted .lcthumb files can each cost ~800 MB. Set max 4096 and wrap. (Needs verification.)
  7. Lightroom import fails without hard links — crates/engine/src/lightroom_archive.rs:428 publish_new is hard-link only; libraries on exFAT/FAT/some SMB can't import a .lrcat. Fall back to safe_file::publish_new_by_rename. (Needs verification.)
  8. JPEG APP segments over 64 KB fail the export — crates/codecs/src/encode.rs:91 (exif.len() > 65_527 => Err) and xmp_segment (> 65_533 => Err("extended XMP not supported")): a long caption/keyword list or a large maker note fails every JPEG export of that photo. Write extended XMP or drop the block with a warning.
  9. Latent arithmetic in raster — crates/raster/src/lib.rs:59-66 Image::new / filled use unchecked width * height; get_clamped with a 0 dimension calls clamp(0, -1), which panics. No input path found today; checked_mul / early return.
  10. GPU nn planner — crates/gpu/src/nn.rs:247 (tile << (-level)), :359, :422 unchecked shift/multiply; unreachable today because the CPU NetRunner validates the model first.
  11. FixBadPixelsList — crates/raw/src/opcodes.rs:608-617 iterates the rows of rectangles whose column range is empty; the count is bounded only by parameter bytes. Skip empty rectangles and cap the count.
  12. Opcode invariants rely on parse_one — apply_list / warp_rectilinear do n - 1, planes.len() - 1; Opcode derives Deserialize, so deserialising lists from an untrusted source would make these panics. Use checked_sub or validate after deserialisation.
  13. Journal and NaN — serde_json writes NaN/inf as null; such a record would pass its CRC but fail to parse, and the library is refused with a misleading "newer version" message. No source of NaN was found; a parse-back check in encode_record would make it impossible.
  14. Windows test failures at f34c7a8a (cargo test --workspace --all-features on Windows 11): engine::tests_export::same_folder_as_original_exports_next_to_each_photo (expects A\Exports, gets A/Exports), engine::tests_segment::a_failing_download_ends_with_an_error_and_never_blocks, mcp::backend::tests::malformed_replies_are_rejected_without_resending (WSAECONNRESET 10054 on loopback), and 8 × ui_egui::tests_folder_drop::* (folder tree with a C: root).

Conditions and impact

See each item.

Recommended remediation

See each item.

Scope / related

CI coverage for Windows is #1050 / PR #1148.


Found in a read-only audit of main at f34c7a8a (AI-assisted, Claude Code; findings were traced in the code, PoCs ran in a scratch checkout outside the repo). Existing issues and open PRs were checked for duplicates before filing.

Activity

  1. ticket-craft commented on Oct 17, 2026

    @ticket-craft

    Thanks! This ticket describes several separate problems:

    • Export file names keep characters Windows forbids
    • FsStore fixed staging name allows collisions without locking
    • Damaged-log copy can be overwritten
    • Bearer token origin ignores the port
    • SAM tokenizer files unpinned and mirrors may be http
    • Thumbnail cache decode has no limits or panic guard

    It helps a lot if each one has its own ticket, so they can be tracked and fixed separately.

    Possibly related: #2122, #2133 and #1740.

  2. PierrunoYT commented on Oct 17, 2026

    @PierrunoYT
    ContributorAuthor

    I'm working on this; a PR will follow.

  3. PierrunoYT commented on Oct 18, 2026

    @PierrunoYT
    ContributorAuthor

    Closing: I'm no longer working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions