Storing credentials in Custom Metadata is considered a vulnerability because Custom Metadata, especially if not protected, can be accessed and modified by the org admin, other packages, or untrusted code within the subscriber org. This exposure increases the risk of unauthorized access to sensitive data, such as API keys or authentication credentials.
The recommended secure alternatives include:
1. **Protected Custom Settings**: These settings are accessible only to the managed package and can securely store sensitive data. A custom UI must be built to allow subscribers to input and manage credentials.
2. **Named Credentials**: These allow secure storage and management of credentials, with the metadata and configuration packaged while the subscriber sets up the actual credentials post-installation.
3. **Encrypted Custom Objects**: Credentials can be encrypted and stored in custom objects, with the encryption key stored separately in a protected custom setting or protected custom metadata field.
Each of these methods ensures that sensitive data is stored securely and access is restricted to authorized components only.