Menu ▾ ▴

#25 Harden avatar handling in the new-message notification bridge

closed
nobody
None
2026-06-29
2026-06-29
Anonymous
No

Originally created by: kristofferR

Follow-up to [#13], addressing two issues CodeRabbit raised while reviewing [#21] (they live in [#13]'s avatar code, so they're fixed here rather than scope-creeping the notification-privacy PR).

Changes

  • Validate the avatar payload as PNG. avatar_to_temp_png previously accepted any data:image/* base64 payload from the remote page and wrote it to a .png file. It now requires a data:image/png;base64, prefix and verifies the decoded bytes begin with the PNG magic header before writing. Size bounds are unchanged.
  • Isolate the avatar temp cache per process. The cache used a single shared $TMP/carrier-avatars directory with process-local sequence names and a startup-wide remove_dir_all, so a second instance (multi_instance) could collide on filenames or delete another instance's in-flight avatars. Each process now uses its own carrier-avatars-<pid> directory; startup cleanup clears only our own directory plus empty leftovers (remove_dir never removes a live instance's non-empty dir).

Validation

cargo fmt / clippy -D warnings clean; cargo test --lib 30 passed. Updated the avatar round-trip test to use real PNG bytes and added rejection cases for non-PNG bytes and non-PNG image subtypes.

Ref [#13]

https://claude.ai/code/session_01XRfsuzbPRNbEFV9hiUEgwv

Related

Tickets: #13
Tickets: #21

Discussion

  • Anonymous

    Anonymous - 2026-06-29

    Ticket changed by: kristofferR

    • status: open --> closed
     
  • Anonymous

    Anonymous - 2026-06-29

    Originally posted by: kristofferR

    @coderabbitai review

     

Log in to post a comment.