feat(ios): 7.1 slice 2 — folder-key server lifecycle + desktop-format wraps, FP plaintext-leak guard (#223) #231

Merged
amiryahaya merged 1 commit from feat/ios-folder-key-lifecycle into main 2026-11-19 17:09:01 +01:00
Owner

Second iOS 7.1 slice: folder keys move from local-only keychain to the SERVER lifecycle, and every plaintext-upload fallback is removed (audit #214 leak family).

Folder-key lifecycle

  • createFolder generates the folder KEK, wraps it hybrid-KEM for the OWNER (createOwnerFolderKeyWrap), and POSTs wrapped_kek/kem_ciphertext (+ owner_* duplicates) — desktop contract
  • New resolveFolderKey chain for uploads/downloads/FP: keychain cache → received-share envelope (/shares/received) → FolderDto wrap → transitional DERIVED fallback (HKDF-SHA256 over the account master key, byte-identical to desktop derive_folder_kek) for the wrap-less tenant root
  • Resolved keys cache to the shared keychain so the FP extension uses server-lifecycle keys too

Leak guards (audit #214 family)

  • Upload: the folder key is MANDATORY — no key, no upload (previously silent plaintext upload)
  • Download: fails LOUDLY if undecryptable; never caches ciphertext (a poisoned cache entry would shadow the real download forever)
  • FileProvider: every plaintext-fallback path throws

Share creation moves to the real contract

  • POST /shares with the desktop-compatible envelope base64(JSON{kem_ciphertext, wrapped_kek}) — the ghost /shares/file + /shares/folder + ShareFileRequest/ShareFolderRequest shapes 400'd every time and are deleted

Known limitation (documented, slice 3): desktop↔iOS folder-key INTEROP is still blocked by the iOS ML-KEM placeholder (HKDF-derived, not ML-KEM-768) and a differing hybrid combine — the wire formats now match, the crypto doesn't. iOS-internal roundtrips are fully working and tested.

Tests: FolderKeyWrapTests — owner-wrap roundtrip, cross-account refusal, desktop-envelope JSON shape. iOS test EXECUTION remains blocked (no macOS runner in fleet — ios-ci runs-on macos-15; local simulator service-hub failure) — compile verified via build-for-testing; server suite 1102 green (untouched surfaces).

Part of M4 epic #223; follow-ups in #222 scope.

Second iOS 7.1 slice: folder keys move from local-only keychain to the SERVER lifecycle, and every plaintext-upload fallback is removed (audit #214 leak family). **Folder-key lifecycle** - createFolder generates the folder KEK, wraps it hybrid-KEM for the OWNER (createOwnerFolderKeyWrap), and POSTs `wrapped_kek`/`kem_ciphertext` (+ owner_* duplicates) — desktop contract - New resolveFolderKey chain for uploads/downloads/FP: keychain cache → received-share envelope (`/shares/received`) → FolderDto wrap → transitional DERIVED fallback (HKDF-SHA256 over the account master key, byte-identical to desktop derive_folder_kek) for the wrap-less tenant root - Resolved keys cache to the shared keychain so the FP extension uses server-lifecycle keys too **Leak guards (audit #214 family)** - Upload: the folder key is MANDATORY — no key, no upload (previously silent plaintext upload) - Download: fails LOUDLY if undecryptable; never caches ciphertext (a poisoned cache entry would shadow the real download forever) - FileProvider: every plaintext-fallback path throws **Share creation moves to the real contract** - `POST /shares` with the desktop-compatible envelope `base64(JSON{kem_ciphertext, wrapped_kek})` — the ghost `/shares/file` + `/shares/folder` + ShareFileRequest/ShareFolderRequest shapes 400'd every time and are deleted **Known limitation (documented, slice 3)**: desktop↔iOS folder-key INTEROP is still blocked by the iOS ML-KEM placeholder (HKDF-derived, not ML-KEM-768) and a differing hybrid combine — the wire formats now match, the crypto doesn't. iOS-internal roundtrips are fully working and tested. **Tests**: FolderKeyWrapTests — owner-wrap roundtrip, cross-account refusal, desktop-envelope JSON shape. iOS test EXECUTION remains blocked (no macOS runner in fleet — ios-ci runs-on macos-15; local simulator service-hub failure) — compile verified via build-for-testing; server suite 1102 green (untouched surfaces). Part of M4 epic #223; follow-ups in #222 scope.
feat(ios): 7.1 slice 2 — folder-key server lifecycle + desktop-format wraps, FP plaintext-leak guard (#223)
All checks were successful
Security CI / security-scan (pull_request) Successful in 5m10s
0c21834c88
Slice 2 of the iOS file-stack migration: folder keys move from
local-only keychain to the SERVER lifecycle, and every plaintext-upload
fallback is removed.

- CryptoManager: createOwnerFolderKeyWrap/openFolderKeyWrap — hybrid KEM
  wrap of the folder KEK to the owner's own keys, POSTed as
  wrapped_kek/kem_ciphertext on folder create (server stores them;
  any device holding the account keys resolves). iOS-internal layout
  documented (kaz ‖ ml concat, SHA256 combine) with the desktop
  divergence (ml ‖ kaz + HKDF) called out for the slice-3 convergence.
- FileRepositoryImpl: createFolder sends the owner wrap; new
  resolveFolderKey chain — keychain cache → /shares/received envelope →
  FolderDto wrap → transitional DERIVED fallback (HKDF-SHA256 over the
  account master key, byte-identical to desktop derive_folder_kek, so
  desktop-legacy root content decrypts on iOS); upload REQUIRES the key
  (plaintext leak posture removed) and download fails LOUDLY instead of
  serving/caching ciphertext.
- ShareRepositoryImpl: shareFile/shareFolder POST the real /shares
  contract with the desktop-compatible envelope
  base64(JSON{kem_ciphertext, wrapped_kek}) (ghost /shares/file +
  /shares/folder 400'd always).
- FileProviderExtension: plaintext-fallback uploads REMOVED — all
  unresolvable paths throw (audit #214 leak family).
- Dead code: MoveRequest/MoveFolderRequest/AccessibleFilesResponse/
  PaginationMeta/ShareFileRequest/ShareFolderRequest removed.
- Share model: fractional-seconds date decoding (server wire format;
  decoder-level .iso8601 silently killed the received-shares parse).
- Tests: FolderKeyWrapTests — owner-wrap roundtrip, cross-account
  refusal, desktop-envelope JSON shape.

Review: dual-pass (ponytail + correctness). Critical findings fixed:
root-folder uploads (wrap-less tenant root → transitional derived key,
desktop-identical), share-create response decode (server returns FLAT
Share, not {data}), received-shares fractional-date decode, download
poisoned-cache elimination. Known limitation (documented): desktop↔iOS
folder-key INTEROP still blocked by the iOS ML-KEM placeholder — slice 3.

iOS unit-test execution remains blocked by the local simulator
service-hub failure and the missing macOS CI runner (ios-ci needs
macos-15; fleet is linux-only) — compile verified via
build-for-testing; server suite 1102 green; desktop TS 1282 green.
Sign in to join this conversation.
No description provided.