Repository navigation
fix(security): fail closed when SPECTOR_MASTER_ENCRYPTION_KEY is unset outside dev/test (#1052) - #1082
Merged
Conversation
…t outside dev/test (#1052) - Add MASTER_KEY_MISSING (SPE-820-002 / SPE-SEC-002) error code to ErrorCode taxonomy - Enforce fail-closed validation in AesGcmCipher outside dev and test profiles - Log prominent WARN banner in dev profile when falling back to deterministic key - Support spector_master_encryption_key in Docker secrets entrypoint loader - Document master encryption key generation, injection, and rotation in deployment docs - Add unit tests in AesGcmCipherTest and Spring Boot contract tests in MasterEncryptionKeyFailClosedTest Co-authored-by: Bharat Joshi <bharatjoshi@spectrayan.com> Signed-off-by: Forge <forge@spectrayan.com>
…ontexts (#1052) Co-authored-by: Bharat Joshi <bharatjoshi@spectrayan.com> Signed-off-by: Forge <forge@spectrayan.com>
sbharatjoshi
approved these changes
Oct 10, 2026
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
Fixes #1052. Ensures that Spector fails closed at boot time when
SPECTOR_MASTER_ENCRYPTION_KEY(orspector.security.master-key) is unset or blank in production environments (outsidedevandtestprofiles), preventing the universal credentials vault and envelope encryption from operating with an insecure fallback key in production.Changes
ErrorCode.java):MASTER_KEY_MISSING(SPE-820-002) with standard aliasSPE-SEC-002.ErrorCode.fromId("SPE-SEC-002").AesGcmCipher.java):Environmentto evaluate active profiles.devortest: aborts startup withIllegalStateException("[SPE-820-002 / SPE-SEC-002] Master encryption key is required outside dev/test profiles (set SPECTOR_MASTER_ENCRYPTION_KEY or spector.security.master-key)").devprofile: emits a prominentWARNbanner alerting developers that the deterministic development key is active and insecure for production.testprofile: permits fallback with a debug log to allow unit and integration test suites to execute without manual key management.spector.security.master-key: ${SPECTOR_MASTER_ENCRYPTION_KEY:}undersecurity:inapplication.yml.deploy/docker/entrypoint.shto support/run/secrets/spector_master_encryption_key:SPECTOR_MASTER_ENCRYPTION_KEY.docs/configuration/deployment-config.mddocumenting key generation (openssl rand -hex 32/openssl rand -base64 32), secret injection methods, and rotation guidelines.AesGcmCipherTest.javaverifying fail-closed behavior on missing keys in prod/default profiles, dev fallback, test fallback, and valid key operation.MasterEncryptionKeyFailClosedTest.javaverifyingApplicationContextRunnerfails fast under prod/default profiles and boots successfully under dev/test or when a key is provided.Verification
mvn test -pl nucleus/spector-commons -Dtest=ErrorCodeTest(586/586 passed)mvn test -pl synapse/spector-synapse -Dtest=AesGcmCipherTest,MasterEncryptionKeyFailClosedTest(16/16 passed)mvn test -pl synapse/spector-synapse -Dtest=CredentialServiceTest,CredentialControllerTest,ConnectorDatabaseLifecycleIT(12/12 passed)mvn license:check(100% compliant across all 29 modules)— Forge (Maintainer)