If your AI API key appears in a data leak, revoke or disable it immediately in the provider’s account dashboard, then create a replacement and update the systems that need it. Treat the exposed key as compromised even if you have no evidence it was used; after containment, check usage and billing, remove the source of exposure, and alert the people responsible for the affected account.
Why an exposed key matters
An API key is a credential that lets software make requests under an account or project. Depending on the provider and the key’s permissions, someone who obtains it may be able to use paid services, consume quotas, access permitted project resources, or create activity that appears to come from your account. The precise capabilities vary, so check the provider’s documentation and account settings rather than assuming every key grants the same access.
A key can leak in a public code repository, a website’s client-side JavaScript, a log, a support ticket, a shared document, a screenshot, or a third-party breach. A key found in a leak does not by itself prove that anyone used it. But it may be copied quickly, and it can be difficult to know how many people or automated systems have already seen a public secret. Rotation is therefore safer than waiting for proof of misuse.
Contain the exposure first
- Revoke the exposed key. Sign in through the provider’s official site and use its key-management controls to revoke or delete that specific credential. If the dashboard offers a temporary disable option and you need to investigate, disable it while you do so. Do not post the key again to ask for help.
- Make a replacement key. Create a new credential only after you have a plan to store and deploy it securely. Apply the narrowest permissions and project scope available for the task. If the provider supports limits or restrictions relevant to your use, configure them; do not rely on restrictions as a substitute for rotation.
- Update dependent applications. Replace the old value in server-side environment settings, secret stores, deployment platforms, scheduled jobs, and other systems that use it. Confirm the application works with the new key, then remove the old value wherever it remains. Avoid putting a secret in a command that may be saved in shell history or displayed in logs.
- Tell the right people. Notify the account owner, security contact, or organization administrator. If the key belongs to a shared project, coordinate the change so other services do not fail unexpectedly.
If the provider’s dashboard is unavailable, contact its support through an official channel and ask how to revoke the credential. If you cannot identify which key leaked, review the account’s keys and usage, and consider rotating any credential that may have been included. Never send the secret itself in an email or support message unless the provider specifically offers a secure procedure for handling it.
Check for use and unexpected charges
After revocation, review available usage, request, and billing records for activity you do not recognize. Look at the time period around the earliest known exposure and continue checking after containment, since reporting data may not update instantly. Compare usage with your own deployments and ordinary traffic. Unfamiliar volume, models, projects, or times can be clues, but they are not conclusive on their own.
Record useful facts for an incident report: when and where the key was discovered, when it was revoked, which applications used it, and what account activity you observed. Preserve relevant logs and alerts in a controlled location, but redact the key from copies shared with others. If you find suspicious activity, contact the provider through its official support or security channel. Ask about available investigation steps and account controls; do not assume a provider will reverse charges or that a particular remedy is guaranteed.
Revoking a key prevents future authentication with that credential, but it does not erase requests already made, undo data already accessed, or automatically remove a copy from every log, cache, or repository. This is why you should both rotate the credential and investigate the systems in which it appeared.
Remove the source and prevent another leak
Fix the exposure point, not just the visible copy. If a key was committed to a repository, remove it from the current files and rotate it; deleting a line in a later commit may leave the secret in earlier history or in other clones. Repository history rewriting can help clean a project, but it does not make an exposed key safe again. Coordinate history changes with collaborators because they can disrupt existing clones and branches.
- Keep credentials on trusted servers. A secret embedded in a web page or mobile application can generally be extracted by users. Have the client call your server, and have that server use the key, with appropriate access controls and monitoring.
- Use environment configuration or a secret manager. Avoid hard-coding keys in source files. Restrict who and what can read stored secrets, and do not print them in application logs, error messages, screenshots, or build output.
- Scan and review. Use repository secret scanning where available, check build and deployment logs, and review changes before publishing. Scanning can miss secrets, so it is one layer of prevention rather than proof that a project is clean.
- Limit exposure and lifetime. Use separate keys for different applications or environments when practical, grant only necessary access, and rotate credentials according to your organization’s policy or after suspected exposure.
A common misconception is that a key is safe because it was visible only briefly or has not produced an obvious charge. Public data may be copied quickly, and some misuse may not be immediately visible. Another is that deleting a leaked file resolves the problem. Once a credential has escaped its intended boundary, revoke it first; cleanup is a separate task.
What to do when the leak is in someone else’s data
If you discover a key in a public repository, paste, or leak report that is not yours, do not test it, use it, or share it. Testing a credential is still an attempt to access an account, and reposting it spreads the exposure. Report it privately to the organization or provider using a published security contact, repository reporting feature, or support channel. Include the location and enough context to help them find it, but redact the secret itself.
If the key is yours and appears in a third-party breach notification, use the provider dashboard directly rather than links in an unexpected message. Revoke the key, then independently verify account activity. Be wary of messages asking you to paste the credential into a form or install software to “secure” it.
Frequently Asked Questions
Should I rotate an AI API key if I am not sure it was exposed?
Yes, if credible evidence suggests the key may have been published, shared outside its intended audience, or included in a breach. Revoking and replacing it is generally a more reliable response than trying to prove nobody copied it.
Can I just delete the leaked key from GitHub or another website?
No. Remove or report the exposed content, but revoke the credential as well. Copies, commit history, caches, or downloads may remain after the visible version is gone.
Will revoking the key stop charges immediately?
It stops new requests authenticated with that key once revocation takes effect, but billing records can lag and other keys or services may still be active. Check usage and billing in the provider account and contact support about suspicious activity.
Is it safe to put an API key in a public website’s code?
Usually not. Code delivered to a browser can be inspected, so a secret included in it should be treated as exposed. Keep the credential on a server and have the site communicate with that server instead.
What if I cannot find the leaked key in my dashboard?
Check the correct provider account, organization, and project, and review any available key history or usage records. If you still cannot locate it, contact official support and explain where it appeared; do not publish the value while seeking help.
Do I need to rotate every key in the account?
Not automatically. Revoke the exposed key and assess whether other credentials were stored or exposed in the same place. Rotate additional keys if they may have been accessible to the same people or systems, or follow your organization’s incident-response policy.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Valheim Server Not Showing in Community List Fixes
- DisplayPort vs HDMI: Which Cable Should You Use?
- Soundbar vs 2.1 Speaker System: Which Is Better?
- Survive Lava for Brainrot Tier List170 points
- MySQL Dump Import: Fix Common Errors
- Mouse Moving on Its Own? Causes & Fixes