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.
Access keys are used to authenticate to Azure Event Grid resources and can be employed for event publication to the resource.
Shared Access Secrets (SAS) are generated from access keys and used to authenticate specific resources with particular permissions within a defined
time frame.
Using Shared Access Signatures is always better than using access keys, because they reduce risk thanks to their scope and time
limitation. However, hardcoding secret tokens is always a bad practice, and still exposes the resources to attacks.
This is a risk unless the
whole resource is free of sensitive data.
Note that the Microsoft docs can use different terminologies for these two tokens:
Below are some real-world scenarios that illustrate some impacts of an attacker exploiting these types of secrets.
When such a secret is compromised, malicious actors might have the possibility to send malicious event objects, causing discrepancies in the audit trail. This can make it difficult to trace and verify the sequence of events, impacting the ability to investigate and identify unauthorized or fraudulent activity.
All in all, this can lead to problems in proving the validity of transactions or actions performed, potentially leading to disputes and legal complications.
If the affected service is used to store or process personally identifiable information or other sensitive data, attackers knowing an authentication secret could be able to access it. Depending on the type of data that is compromised, it could lead to privacy violations, identity theft, financial loss, or other negative outcomes.
In most cases, a company suffering a sensitive data compromise will face a reputational loss when the security issue is publicly disclosed.
Financial losses can occur when a secret is used to access a paid third-party-provided service and is disclosed as part of the source code of client applications. Having the secret, each user of the application will be able to use it without limit to use the third party service to their own need, including in a way that was not expected.
This additional use of the secret will lead to added costs with the service provider.
Moreover, when rate or volume limiting is set up on the provider side, this additional use can prevent the regular operation of the affected application. This might result in a partial denial of service for all the application’s users.
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 are 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.
On top of that, use the Azure SDK as much as possible and their diverse credential objects.
props.set("aeg-sas-token", "r=https%3a%2f%2fexample.westeurope-1.eventgrid.azure.net%2fapi%2fevents&e=1%2f1%2f0001%2012%3a02%3a52%20AM&s=gdcIr5dXR4dC3sNyK4Qree4XogaRma3YdtH7%2boCxSQo%3d") // Noncompliant
props.set("aeg-sas-token", System.getenv("AEG_SAS_TOKEN"))