FAQ-000551 - Custom Settings and Configuration Security / Specific Use Cases and Implementation Patterns

Current Status:VALID_RESPONSEErrorUnable to AnswerSuggests Case

Current FAQ

Question
How should custom settings be used for secure token storage?
Answer
To securely store tokens using custom settings, follow these best practices: 1. **Use Protected Custom Settings**: Create a custom settings object with visibility set to "Protected" to ensure sensitive data is not accessible to unauthorized users or external packages. 2. **Replace References**: Update all references in your managed package to use the new protected custom settings object. 3. **Encrypt Sensitive Data**: If required, encrypt sensitive data and store the encryption key securely within the protected custom settings. 4. **Avoid GUI Interfaces**: Protected custom settings lack built-in GUI interfaces for management, so include secure code in your application to update these settings. 5. **Use the Transient Keyword**: Prevent sensitive data from being stored in the viewstate by using the `transient` keyword. These steps help ensure secure token storage and protect sensitive information.
Enhancing FAQ...

Enhancing FAQ with AI recommendations...

AI Recommended Enhancement

Related Security Rules (click to view)
ApexSuggestUsingNamedCredAvoidHardcodedCredentialsInFieldDeclsAvoidHardcodedCredentialsInVarDeclsAvoidHardcodedCredentialsInVarAssignProtectSensitiveDataApexBadCrypto
Question
How should custom settings be used for secure token storage?
Recommended Answer Update
To securely store tokens using custom settings, follow these best practices: 1. **Use Protected Custom Settings**: Create a custom settings object with visibility set to "Protected" to ensure sensitive data isn't accessible to unauthorized users or external packages. 2. **Replace References**: Update all references in your managed package to use the new protected custom settings object. 3. **Encrypt Sensitive Data**: If required, encrypt sensitive data and store the encryption key securely within the protected custom settings. 4. **Avoid GUI Interfaces**: Protected custom settings lack built-in GUI interfaces for management, so include secure code in your application to update these settings. 5. **Use the Transient Keyword**: Prevent sensitive data from being stored in the viewstate by using the `transient` keyword. These steps help ensure secure token storage and protect sensitive information.
Reasoning
The FAQ content is generally sound and follows security best practices. I made minor improvements to enhance clarity and readability: changed 'is not accessible' to 'isn't accessible' for a more conversational tone per the brand guidelines. The technical content aligns well with multiple security rules that address token and credential management. Regarding security rules selection: - ApexSuggestUsingNamedCred: Directly relates to the FAQ's focus on secure token storage, as this rule suggests using Named Credentials instead of hardcoded tokens - AvoidHardcodedCredentialsInFieldDecls: Relates to point #1 about using Protected Custom Settings to avoid exposing sensitive data in field declarations - AvoidHardcodedCredentialsInVarDecls: Connects to the overall guidance about secure token storage and avoiding hardcoded credentials in variable declarations - AvoidHardcodedCredentialsInVarAssign: Aligns with the FAQ's guidance on secure token management and avoiding hardcoded credentials in assignments - ProtectSensitiveData: Directly applicable to the entire FAQ content which focuses on protecting sensitive token information using custom settings - ApexBadCrypto: Relates to point #3 about encrypting sensitive data, as this rule addresses proper cryptographic practices
Reasoning References