Secure OAuth client secret storage and prevent API exposure #2204
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.
🔒 OAuth Client Secret Security Fix
This PR addresses a critical security vulnerability where OAuth client secrets were being stored as in run config and exposed in export API.
🚨 Security Issue
Problem: OAuth client secrets provided via CLI were being stored as plain text in
RunConfigand exposed in export/detail API responses, creating a security vulnerability.Impact: Sensitive OAuth credentials were visible in API responses, potentially exposing them to unauthorized users.
🛡️ Security Solution
Secure Secret Storage:
"SECRET_NAME,target=oauth_secret") are stored inRunConfigCentralized Processing:
🛠️ Technical Implementation
New Security Functions:
processOAuthClientSecret()- Converts plain text secrets to secure referencesgenerateOAuthClientSecretName()- Creates unique secret names based on workloadfindUniqueSecretName()- Handles secret name conflicts with timestamp resolutionstoreSecretInManager()- Secure secret storage with error handlingSecretParameter.ToCLIString()- CLI format string conversionEnhanced Secret Resolution:
WithSecrets()method to resolve OAuth client secrets during runtimeComprehensive Testing:
📊 Files Changed
cmd/thv/app/run_flags.go- OAuth secret processing and CLI integrationpkg/api/v1/workload_service.go- API secret handling and conversionpkg/runner/config.go- Secret resolution and validationpkg/runner/runner.go- Secret resolution integrationpkg/secrets/types.go- CLI string conversion utilitiescmd/thv/app/oauth_secret_test.go- Comprehensive unit tests🔄 Breaking Changes
None - This is a security fix that maintains backward compatibility while improving security posture.
🎯 Security Impact
RunConfigand exposed in APIs🔍 Verification
🚀 Benefits
This PR resolves the OAuth client secret security vulnerability while maintaining full backward compatibility and functionality.