feat/implement environment-aware defaults and fail-closed secrets (US-1, US-2 #2595)#2847
Open
EleniKechrioti wants to merge 3 commits intoIBM:mainfrom
Open
feat/implement environment-aware defaults and fail-closed secrets (US-1, US-2 #2595)#2847EleniKechrioti wants to merge 3 commits intoIBM:mainfrom
EleniKechrioti wants to merge 3 commits intoIBM:mainfrom
Conversation
- Added detection for sentinel values ('', 'UNCONFIGURED')
- Defined weak/default secret constants for production validation
- Enhanced get_security_status() with specific error codes and risks
- Implemented log_critical_issues() with remediation and documentation links
- Enforced application termination (SystemExit) in production environments
- Added unit tests to verify security gates and development-mode bypass
Signed-off-by: Eleni Kechrioti <elenikehrioti@gmail.com>
- Implement default_factory for REQUIRE_STRONG_SECRETS based on ENVIRONMENT - Add audit logging for production security overrides - Update .env.example, configuration reference, and CHANGELOG - Add unit tests for production/development scenarios Closes US-1 Signed-off-by: Eleni Kechrioti <elenikehrioti@gmail.com>
Member
|
Thanks @EleniKechrioti. Fail-closed on weak secrets in production is an important security improvement. Code review observations:
|
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.
Related Issue
Partially addresses #2595 . Implements US-1 (Environment-Aware Defaults) and US-2 (Fail-Closed on Unconfigured Secrets).
Summary
This PR implements the Fail-Closed security mechanism for US-2. It ensures the Gateway terminates execution if critical security secrets are missing, unconfigured, or weak when running in production mode.
Key Changes:
Environment-Aware Enforcement (US-1)
default_factoryforrequire_strong_secrets, automatically enabling enforcement (true) inproductionand disabling it (false) indevelopment.Fail-Closed Mechanism (US-2)
JWT_SECRET_KEYorAUTH_ENCRYPTION_SECRETare missing, weak, or set to default values.get_settings()to trigger aSystemExitin production mode when critical security risks are detected.init_secretsscript and official IBM security docs.Documentation & Testing
.env.example,CHANGELOG.md, andconfiguration.mdto document the new environment-aware behavior and breaking changes.tests/test_config_security.pycovering all environment-specific scenarios.Type of Change
Verification
make lintmake testmake coverageNote: Verified specifically with
pytest tests/test_config_security.py.Checklist
make black isort pre-commit)Notes
Manual verification performed:
ENVIRONMENT=productionwith empty secrets correctly triggersSystemExit(1).ENVIRONMENT=developmentcorrectly proceeds with warnings.init_secretsscript and official IBM documentation.