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?
A RapidAPI key is a unique identifier that allows you to access and use APIs provided by RapidAPI. This key is used to track your API usage, manage
your subscriptions, and ensure that you have the necessary permissions to access the APIs you are using. One RapidAPI key can be used to authenticate
against a set of multiple other third-party services, depending on the key entitlement.
If a RapidAPI key leaks to an unintended audience, it can have several potential consequences. Especially, attackers may use the leaked key to
access and utilize the APIs associated with that key without permission. This can result in unauthorized usage of API services, potentially leading to
misuse, abuse, or excessive consumption of resources.
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.
Analyze recent secret use
When available, analyze authentication logs to identify any unintended or malicious use of the secret since its disclosure date. Doing this will
allow determining if an attacker took advantage of the leaked secret and to what extent.
This operation should be part of a global incident response process.
RapidAPI services include an audit trail feature that can be used to audit malicious use of the compromised key.
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("rapidapi_key", "6f1bbe24b9mshcbb5030202794a4p18f7d0jsndd55ab0f981d")
Compliant solution
props.set("rapidapi_key", System.getenv("rapidapi_key"))
Resources
Standards
Documentation