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.

Why is this an issue?

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.

What is the potential impact?

Application keys and secrets allow applications to authenticate with Huawei Cloud services. If an application secret is disclosed, an attacker will be able to call Huawei Cloud resources with the same privileges as the application.

Below are some real-world scenarios that illustrate some impacts of an attacker exploiting the secret.

Phishing and spam

An attacker can use this application secret to spam users or lure them into links to a malicious domain controlled by the attacker.

Spam can cause users to be exposed to the following:

Once a user has been phished on a legitimate-seeming third-party website, an attacker can collect the user’s credentials, bypass multi-factor authentication (MFA), and take over the user’s account on the trusted website.

Financial loss

Cloud providers charge for their services based on their usage. This may be based on the number of API calls made, bandwidth, or how many server instances are running.

An attacker can use a disclosed secret to send large numbers of requests to the cloud provider. This can lead to a large and unexpected increase in cloud provider costs.

Denial of service

The cloud provider may monitor requests to identify unusual usage activity. If an attacker is able to send enough requests, the cloud provider may flag your account and take action against it. This could lead to the suspension or termination of your account, thus causing significant inconvenience and disruption for your customers or partners.

How to fix it

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.

Code examples

Noncompliant code example

props.set("huawei-cloud.app-secret", "2bcd82072fdd4d396eadd7095a27c0f2f93d527618605a631107fb75026b59cb") // Noncompliant

Compliant solution

props.set("huawei-cloud.app-secret", System.getenv("HUAWEI_CLOUD_APP_SECRET"))

Resources

Documentation

Standards