app-storage: re-gate MockEncryptionStorage behind mock feature#73
Merged
jgowdy-godaddy merged 1 commit intomainfrom Apr 17, 2026
Merged
app-storage: re-gate MockEncryptionStorage behind mock feature#73jgowdy-godaddy merged 1 commit intomainfrom
jgowdy-godaddy merged 1 commit intomainfrom
Conversation
#71 made the mock backend always-compiled so ENCLAVEAPP_MOCK_STORAGE could be honored at runtime without cargo feature gymnastics. That is a security hole for release binaries: anyone setting the env var on a production install would downgrade the hardware-backed backend to an AES-in-RAM mock. Restore the compile-time gate: - `mock` cargo feature opt-in, with aes-gcm/rand/sha2 as optional deps only pulled in by the feature. - `mock` module, `MockEncryptionStorage` re-export, `MOCK_STORAGE_ENV` constant, and the env-var check inside `create_encryption_storage` all gated on `#[cfg(feature = "mock")]`. - Release builds (no --features mock) have no path to the mock at all — setting ENCLAVEAPP_MOCK_STORAGE in production is a no-op. - Test builds enable the feature via downstream `[dev-dependencies]` with `features = ["mock"]`; cargo unifies features during `cargo test`, so the env var works in CI as intended. Keeps #72's deterministic key derivation inside the gated mock module so cross-process test spawning still works.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#71 made the mock backend always-compiled so `ENCLAVEAPP_MOCK_STORAGE` could be honored at runtime. That was wrong: a runtime flag in a production binary lets anyone with the env var swap the hardware-backed backend for an in-RAM AES mock. Security hole.
Re-gate: `mock` cargo feature opt-in. Release builds (`cargo build`) have no path to the mock. Test builds (`cargo test`) pull it in via downstream `[dev-dependencies]` with `features = ["mock"]` — cargo feature unification turns it on during tests only.
Keeps #72's deterministic key derivation so cross-process integration tests still work.
Mechanical changes
Follow-ups
Test plan