Skip to content

feat: add end-to-end encrypted kDrive vault - #17

Open
OpenCow42 wants to merge 4 commits into
mainfrom
codex/encrypted-kdrive-vault
Open

feat: add end-to-end encrypted kDrive vault#17
OpenCow42 wants to merge 4 commits into
mainfrom
codex/encrypted-kdrive-vault

Conversation

@OpenCow42

@OpenCow42 OpenCow42 commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • define incompatible encrypted-vault format v2 (KPE2/KPC2/KPB2, KPV2 recovery kits, and ev2: File Provider identifiers) while retaining v1 configuration decoding only to fail closed
  • unify new-vault, recovery-kit, and iCloud activation behind the disabled-by-default EncryptedVaultsEnabled gate, the complete-data-loss/no-support warning, and an independently enforced five-second monotonic delay
  • harden deterministic journal replay against parent cycles, unsafe trash restoration, and generated sibling-name collisions
  • restore historical content through fresh authenticated ciphertext and a fresh logical revision to prevent ABA stale writes
  • use authenticated power-of-two checkpoint padding and disable remote content/journal deletion that cannot be proven safe for offline devices
  • remove the incomplete migration/source-purge coordinator and its product claims
  • add a normative conflict-safety register, regression coverage, and iOS/visionOS CI unit-test jobs

Security status

  • disabled by default; the main flag gates activation UI and is not a runtime kill switch for an already registered v2 domain
  • not approved for production use
  • independent cryptographic and adversarial synchronization review remains a critical release gate
  • external history witnessing, safe compaction, full rekey/revocation, safe migration/source purge, and documented metadata-leakage limitations remain open release gates in doc/CONFLICT_RESOLUTION_TRUTH_TABLE.md

Validation

  • git diff --check: passed
  • macOS: complete test bundle built with build-for-testing; 33 focused journal, provisioning/maintenance, cryptography, and domain-format tests passed directly
  • iOS 26.5 iPhone 17 Simulator: complete potassiumProviderTests target passed
  • visionOS 26.5 Apple Vision Pro Simulator: complete potassiumProviderTests target passed; affected format/crypto/activation suites passed again after the final fail-closed changes
  • unsigned iOS Simulator and generic visionOS builds: passed
  • targeted macOS warning UI automation: passed

The normal local macOS test host executed the activation-model assertions but hung while finalizing its Xcode result bundle; this PR does not represent that run as a clean full-host exit.

@OpenCow42 OpenCow42 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review outcome: changes required before merge. I reviewed the cryptographic format and key custody, journal/reducer convergence, local encrypted persistence, rollback/checkpoint/GC behavior, migration, File Provider routing and item versions, trash/version semantics, onboarding, documentation, and the new tests. The feature is appropriately disabled by default and documented as experimental, but the findings below include reproducible state-corruption and stale-write paths. I submitted a comment review because GitHub does not allow an author to request changes on their own PR.

Comment thread PotassiumProviderCore/VaultJournal.swift Outdated
Comment thread PotassiumProviderCore/EncryptedVaultService.swift Outdated
Comment thread PotassiumProviderCore/VaultJournal.swift Outdated
Comment thread PotassiumProviderCore/VaultJournal.swift Outdated
Comment thread PotassiumProviderCore/VaultMaintenance.swift Outdated
@OpenCow42

Copy link
Copy Markdown
Owner Author

Added the mandatory unsupported-feature/data-loss gate in bee9f3b. The warning now appears before any remote vault preparation, explicitly states that complete unrecoverable data loss is possible, that no party provides support, and that the user proceeds entirely on their own. The continuation button is disabled for five seconds, with the same boundary enforced in the app model. Validation: focused macOS model tests passed (including 4.999s rejection and 5.000s acceptance with zero remote objects before acceptance); the targeted macOS UI test passed; iOS Simulator and unsigned generic visionOS builds passed.

@OpenCow42

Copy link
Copy Markdown
Owner Author

Self-review completed on commit a0e0839.

Addressed and resolved all five inline review findings:

  • deterministic journal replay no longer traps on cycles; proposed and final parent graphs are validated;
  • historical-version restore decrypts/authenticates and re-encrypts into a fresh revision, preventing ABA reuse;
  • trash/restore tracks trash-root provenance so independently trashed descendants are not revived;
  • sibling-name collisions are allocated deterministically while reserving normalized names;
  • checkpoints use authenticated length framing plus random power-of-two padding, and reject malformed, tampered, unpadded, or out-of-range data.

Additional fail-closed findings caught during self-review and fixed:

  • unsupported v1 configurations are rejected before token/key/network access, including the currentSyncAnchor path;
  • the embedded vault format is checked independently, so a v2 configuration cannot smuggle v1 ciphertext;
  • app reload no longer re-registers an unsupported v1 domain;
  • remote deletion/retention GC was removed because offline devices make reachability unprovable;
  • the incomplete migration/source-purge path and related product claims were removed;
  • activation and recovery both require the explicit loss/unsupported warning, with a model-enforced monotonic 5-second delay before any side effect.

Validation:

  • GitHub Actions run 30750062247 passed on macOS, iOS Simulator, and visionOS;
  • local full potassiumProviderTests passed on iOS Simulator and visionOS;
  • focused macOS cryptography, provisioning, journal, and domain suites passed (33 tests);
  • macOS build-for-testing and generic visionOS build passed.

This is not a production approval. The normative safety register in doc/CONFLICT_RESOLUTION_TRUTH_TABLE.md still marks EV-009 through EV-014 open: new-device history witnessing, safe journal compaction/scale, complete rekey/revocation, safe migration/source purge, metadata/access-pattern leakage, and independent cryptographic/adversarial review.

I did not change the PR's draft/readiness, approval, or merge state.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant