FAQ-000702 - Data Storage and Encryption Security / Encryption and Key Management

Current Status:VALID_RESPONSEErrorUnable to AnswerSuggests Case

Current FAQ

Question
How should I handle encryption for sensitive data stored in the database?
Answer
To handle encryption for sensitive data stored in the database in Salesforce, follow these best practices: 1. **Use Protected Custom Metadata or Settings**: Store sensitive data like API keys or passwords in protected custom metadata or settings to prevent unauthorized access. 2. **Encrypt Data in Custom Objects**: If sensitive data is stored in custom objects, use AES-128 or higher encryption standards. Keep the encryption key in a protected custom setting or hidden custom metadata API field. 3. **Avoid Encrypted Fields for Authentication Data**: Use named credentials or protected custom settings instead of encrypted fields for storing authentication data. 4. **Configure Permissions**: Ensure only authorized users can access fields containing encrypted secrets. 5. **Use Salesforce Cryptography APIs**: Leverage Apex Crypto calls for encryption and decryption, avoiding custom cryptography solutions. 6. **Regular Reviews**: Periodically review your implementation to ensure compliance with Salesforce's security standards. By following these guidelines, you can securely manage sensitive data in Salesforce.
Enhancing FAQ...

Enhancing FAQ with AI recommendations...

AI Recommended Enhancement

Related Security Rules (click to view)
ApexBadCryptoApexSuggestUsingNamedCredAvoidHardcodedCredentialsInFieldDeclsAvoidHardcodedCredentialsInVarDeclsAvoidHardcodedCredentialsInVarAssignProtectSensitiveData
Question
How should I handle encryption for sensitive data stored in the database?
Recommended Answer Update
To handle encryption for sensitive data stored in the database in Salesforce, follow these best practices: 1. **Use Protected Custom Metadata or Settings**: Store sensitive data like API keys or passwords in protected custom metadata or settings to prevent unauthorized access. 2. **Encrypt Data in Custom Objects**: If sensitive data is stored in custom objects, use AES-256 or higher encryption standards. Keep the encryption key in a protected custom setting or protected custom metadata. 3. **Avoid Encrypted Fields for Authentication Data**: Use named credentials or protected custom settings instead of encrypted fields for storing authentication data. 4. **Configure Permissions**: Ensure only authorized users can access fields containing encrypted secrets. 5. **Use Salesforce Cryptography APIs**: Leverage Apex Crypto calls for encryption and decryption, avoiding custom cryptography solutions. 6. **Regular Reviews**: Periodically review your implementation to ensure compliance with Salesforce's security standards. By following these guidelines, you can securely manage sensitive data in Salesforce.
Reasoning
The FAQ has good foundational content but needs refinement in two key areas: 1. **Outdated encryption standard**: The answer recommends "AES-128 or higher" which is outdated. Modern security standards recommend AES-256 as the minimum for new implementations. 2. **Imprecise terminology**: The phrase "hidden custom metadata API field" is unclear and potentially confusing. Protected custom metadata is the more accurate and standard term. These changes improve accuracy while maintaining all original points and structure. **Security Rules Reasoning**: - **ApexBadCrypto**: Directly relates to the FAQ's point about "Use Salesforce Cryptography APIs" and avoiding custom cryptography solutions, which this rule detects. - **ApexSuggestUsingNamedCred**: Connects to the FAQ's recommendation to "use named credentials...instead of encrypted fields for storing authentication data." - **AvoidHardcodedCredentialsInFieldDecls**: Relates to the FAQ's guidance on storing "sensitive data like API keys or passwords" properly rather than hardcoded. - **AvoidHardcodedCredentialsInVarDecls**: Connects to the FAQ's emphasis on proper storage of sensitive credentials. - **AvoidHardcodedCredentialsInVarAssign**: Relates to the FAQ's recommendations about avoiding improper credential storage. - **ProtectSensitiveData**: Directly aligns with the overall FAQ topic of "encryption for sensitive data stored in the database."
Reasoning References