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.
Below are some real-world scenarios that illustrate some impacts of an attacker exploiting the secret.
The leaked key can be used to query APIs of blockchain services and access sensitive information stored in the service metadata. This may include
user identities and other sensitive data.
Such disclosure compromises user privacy and confidentiality.
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.
Since this secret is used to process transaction-related operations, financial loss may also occur if transaction-related objects are corrupted or
the account is tampered with.
This can range from indirect losses to direct unauthorized transfers of funds that can lead to bankruptcy or
impoverishment of individuals.
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.
props.set("infura_api_key", "https://mainnet.infura.io/v3/f6fc4aa25abb16e901876269d01f2ec5") // Noncompliant
props.set("infura_api_key", System.getenv("INFURA_API_KEY"))