FAQ-000714 - Data Storage and Encryption Security / Secure Storage Best Practices

Current Status:VALID_RESPONSEErrorUnable to AnswerSuggests Case

Current FAQ

Question
What are the best practices for secure storage of sensitive data in managed packages?
Answer
To securely store sensitive data in managed packages, follow these best practices: 1. **Protected Custom Settings or Metadata**: Store sensitive data like API keys and passwords in protected custom settings or metadata fields to prevent unauthorized access. 2. **Encryption**: Encrypt sensitive data using strong algorithms like AES-128 or higher, and store encryption keys separately in protected settings or metadata. 3. **Named Credentials**: Use named credentials for locally generated or per-org secrets, but note that administrators can view these. 4. **Avoid Public Visibility**: Ensure sensitive fields in custom objects are not publicly visible. 5. **Apex Crypto Library**: Use Salesforce's Apex Crypto library for encryption and decryption, avoiding custom cryptography. 6. **Transient Keyword**: Use the `transient` keyword in code to prevent sensitive data from being stored in viewstate. 7. **Audit and Validation**: Regularly audit your package to ensure sensitive data is stored securely, validate user input, and avoid logging sensitive data. 8. **Secure Web Services**: Encrypt and securely store credentials for web services, avoiding storage in browser apps or client-side code. 9. **Documentation**: Document sensitive data storage and disclose storage locations and providers to customers. 10. **Mitigation Strategies**: Implement strategies to prevent vulnerabilities like prompt injection and validate all user inputs. These steps will help maintain the confidentiality and integrity of sensitive data in your managed packages.
Enhancing FAQ...

Enhancing FAQ with AI recommendations...

AI Recommended Enhancement

Related Security Rules (click to view)
ApexBadCryptoApexSuggestUsingNamedCredAvoidHardcodedCredentialsInFieldDeclsAvoidHardcodedCredentialsInVarDeclsAvoidHardcodedCredentialsInVarAssignAvoidHardcodedCredentialsInHttpHeaderProtectSensitiveData
Question
What are the best practices for secure storage of sensitive data in managed packages?
Recommended Answer Update
To securely store sensitive data in managed packages, follow these best practices: 1. **Protected Custom Settings or Metadata**: Store sensitive data like API keys and passwords in protected custom settings or metadata fields to prevent unauthorized access. 2. **Encryption**: Encrypt sensitive data using strong algorithms like AES-256 or higher, and store encryption keys separately in protected settings or metadata. 3. **Named Credentials**: Use named credentials for locally generated or per-org secrets, but note that administrators can view these. 4. **Avoid Public Visibility**: Ensure sensitive fields in custom objects aren't publicly visible. 5. **Apex Crypto Library**: Use Salesforce's Apex Crypto library for encryption and decryption, avoiding custom cryptography. 6. **Transient Keyword**: Use the `transient` keyword in code to prevent sensitive data from being stored in viewstate. 7. **Audit and Validation**: Regularly audit your package to ensure sensitive data is stored securely, validate user input, and avoid logging sensitive data. 8. **Secure Web Services**: Encrypt and securely store credentials for web services, avoiding storage in browser apps or client-side code. 9. **Documentation**: Document sensitive data storage and disclose storage locations and providers to customers. 10. **Mitigation Strategies**: Implement strategies to prevent vulnerabilities like prompt injection and validate all user inputs. These steps help maintain the confidentiality and integrity of sensitive data in your managed packages.
Reasoning
The FAQ content is mostly accurate but needs minor improvements for clarity and security best practices. Key changes made: 1) Updated encryption recommendation from 'AES-128 or higher' to 'AES-256 or higher' to align with current security standards and ApexBadCrypto rule guidance. 2) Improved readability by changing 'will help maintain' to 'help maintain' for more conversational tone. 3) Changed 'are not publicly visible' to 'aren't publicly visible' for better conversational flow. Selected security rules all directly relate to the FAQ content: ApexBadCrypto relates to points 2 and 5 about proper encryption and using Salesforce's crypto libraries; ApexSuggestUsingNamedCred relates to point 3 about named credentials usage; AvoidHardcodedCredentials rules (FieldDecls, VarDecls, VarAssign, HttpHeader) all relate to points 1, 8, and general secure storage practices; ProtectSensitiveData encompasses the overall theme of secure sensitive data handling discussed throughout the FAQ.
Reasoning References
Recommended Related Articles