Secret leaks often occur when a sensitive piece of authentication data is stored with the source code of an application. Considering the source code is intended to be deployed across multiple assets, including source code repositories or application hosting servers, the secrets might get exposed to an unintended audience.
In most cases, trust boundaries are violated when a secret is exposed in a source code repository or an uncontrolled deployment environment. Unintended people who don’t need to know the secret might get access to it. They might then be able to use it to gain unwanted access to associated services or resources.
The trust issue can be more or less severe depending on the people’s role and entitlement.
SendGrid keys are used for authentication and authorization when using the SendGrid email delivery service.
If a SendGrid key were to accidentally fall into the hands of unintended recipients, it could have severe repercussions for your email delivery.
Firstly, unauthorized individuals who gain access to your SendGrid account could exploit its features to send emails on your behalf. This unauthorized access might result in the sending of spam emails, phishing attempts, or other forms of unsolicited and potentially harmful content. This not only compromises the integrity of your email communications but also poses a risk to the recipients who may unknowingly engage with malicious messages.
Secondly, the leaked SendGrid key could trigger a high volume of email activity, potentially raising suspicions. SendGrid, being vigilant about such activities, may flag your account and take action against it. This could lead to the suspension or termination of your SendGrid account, disrupting your email delivery service and causing significant inconvenience and potential loss of communication with your customers or clients.
Revoke the secret
Revoke any leaked secrets and remove them from the application source code.
Before revoking the secret, ensure that no other applications or processes is using it. Other usages of the secret will also be impacted when the secret is revoked.
Use a secret vault
A secret vault should be used to generate and store the new secret. This will ensure the secret’s security and prevent any further unexpected disclosure.
Depending on the development platform and the leaked secret type, multiple solutions are currently available.
props.set("sg_key", "SG.Wjo5QoWqTmrFtMUf8m2T.CIY0Z24e5sJawIymiK_ZKC_7I15yDP0ur1yt0qtkR9Go")
props.set("sg_key", System.getenv("SG_KEY"))