Key takeaways
- Removing a key from the current code does not disable copies. Work in the provider’s dashboard to revoke or rotate it.
- List the app components that use the credential and decide how to protect users during the change.
- Check usage, billing, and audit records during the possible exposure window. Store replacement secrets only where the app needs them.
- Some identifiers are intentionally public. The provider’s documentation and the key’s privileges determine how to handle it.
What counts as an exposed API key?
An API key identifies or authorizes a request to another service, depending on how the provider designed it. A key is exposed when a credential intended to stay private becomes available outside the people or systems allowed to use it. A public repository is an obvious example. A released browser bundle, debug export, or app build may also contain values the team intended to use only on a server.
Think beyond the file where a key was found. What service issued the credential, which account owns it, what actions are allowed, and where does the app use it? These details determine the consequences and how quickly you need to change access. A testing credential with restricted access deserves attention. A production credential with broad access to customer records or an expensive service usually needs immediate escalation.
Look up the key type in the actual provider’s docs. Some services expect a public application identifier to appear on a browser or phone. Others offer separate public and privileged credentials. Follow any required restrictions and enforce data access on the appropriate server or managed backend. The fact that you can see a value does not, by itself, tell you what the value can do.
| What you found in an approved review | Who to involve | First decision |
|---|---|---|
| Privileged production API key in public code | Service owner and incident lead | Disable the old key and decide how to keep essential workflows available |
| Key in a released browser or phone app | App owner, engineer, and provider administrator | Move privileged actions to a trusted service and plan the credential change |
| Test credential shared in a workspace | Test environment administrator | Confirm whether the key can reach real services and rotate if required |
| Documented public client identifier | Application and data owners | Verify permitted origins where supported and the access rules protecting data |
| Value found by a scanner but key type uncertain | Repository owner and credential administrator | Identify the issuing provider using safe metadata |
How can you tell where your app exposed a secret?
Use your company’s approved repository scanning tools and credential inventory. Review the specific app environments where the key was used. A developer can check whether deployment configuration inserts it into server code or a publicly delivered build. Confirm which builds reached users and whether older copies are accessible through the normal release channels.
Scan source branches and relevant history through your organization’s configured tools. Ask the release owner about archived builds, logs, and automated job output. A clean current file says something useful about the latest version. It does not establish when a credential first became public or whether an earlier copy remains in the wild.
Avoid spreading the value while doing the review. Refer to a provider-generated key ID, a masked label, or the alert number. Remove sensitive values from notes and screen recordings. Discuss the findings in the incident channel approved by your company. Ask the provider administrator to confirm the credential and permissions using the provider’s own interface.
GitHub’s guidance recommends identifying the secret and affected services, revoking it, checking for unauthorized access, cleaning the repository, and preventing a repeat. Use its tutorial to assign owners to those steps. GitHub’s leaked-secret response guide.
What order should you follow to rotate a key?
The order depends on the credential’s privilege, how certain you are that it is exposed, and how important the affected service is to users. An active high-risk production secret may need to be disabled immediately. When short overlap is safe and your provider supports it, an engineer may deploy a restricted replacement first so essential work can continue. Decide explicitly with the owner who can authorize the change. Set a deadline to disable the original and record when that happens.
- Identify the old credential and its use. Map it to the provider account, environment, and authorized actions. Ask who can see provider logs and revoke access.
- Choose the safest interruption plan. Review whether ongoing data or financial exposure calls for immediate revocation. If a controlled handoff is appropriate, specify the allowed overlap.
- Create and store a restricted replacement. Use the provider’s controls and your approved secret store. Access should match the specific job the application needs.
- Update every intended consumer. This can include the primary web server, a separate worker, scheduled imports, and deployment automation. Keep the value out of screenshots and change notes.
- Revoke the old key and verify the result. Confirm the old credential is disabled in the provider dashboard. Use normal approved app operations with safe data to confirm the replacement works.
- Check the exposure window. Review services and logs from when the value may first have appeared through revocation. Document behavior that needs follow-up and identify who owns it.
An owner without deployment access can still prepare useful information. Write down the service name, the app function involved, and who pays for and administers it. Have someone available to check that business operations recover after the change. If changes affect active payment, order, or support flows, decide who will tell the affected people and how you will reconcile work received during any interruption.
Google Cloud’s advice illustrates several practices that apply widely. Use restrictions where supported, keep private credentials out of client code, and review how the provider records key usage. Refer to the actual service instructions when choosing restrictions or authentication alternatives. Google Cloud’s API key guidance.

What should you check after disabling the exposed key?
Confirm there is an audit trail for revocation and that all permitted callers work under the replacement. Check activity against your normal billing and usage patterns. Some providers show detailed activity by credential, while others provide general logs or billing records. Ask the administrator what records exist and how far they go back. Keep the raw credential out of the incident timeline.
Look for changes to the data or account resources the key could access. An unusual number of requests deserves investigation, and ordinary-looking usage can still require follow-up if account activity is difficult to attribute. Write down what you can confirm and which questions remain open. If the credential could access sensitive data or protected systems, your security owner and qualified counsel can assess the response and any obligations.
Having a working app again is one check. Also make sure an old worker, emergency restore, or test environment cannot reintroduce the exposed value. Update the instructions the team uses for the next release, including any safe method for replacing a key during an incident. If a public build contained a privileged value, make sure the app relies on a trusted service for that action before preparing another release.
Artemesis is a Bangladesh-based team that works remotely with U.S. businesses. If you need help identifying which parts of an AI-built app use sensitive credentials, book an app security consultation. Bring the service and workflow names. Keep the credentials in your approved tools.
Does deleting the key from the repository solve the problem?
Deleting the value from the current files helps prevent the app from using or publishing it again. A key that was already published needs action at the provider. A team can decide whether to clean earlier Git history after it disables the credential. History cleanup affects collaborators and automated deployment references, so make that change deliberately and verify which copies the team can actually control.
Check whether the original code behaved differently from the way your team intended. For example, a browser task may be performing a privileged operation directly. After rotating the key, move that operation into a service that controls who may ask for it and limits which records the action touches. Test the permissions with approved staging identities so the result is clear before release.
Example scenario, not a real client. A founder realizes that the browser version of a quoting tool includes a credential for a paid document service. The incident owner asks the service administrator to disable it and watches for unexpected usage. The engineer changes the app so the browser requests a quote through the app’s business-owned server, the server verifies the role, and a restricted server credential generates the document. A test confirms authorized staff can still create a quote and that the old credential is disabled. The product owner records who can rotate the new credential later.
How do you reduce the chance of a repeat?
Use separate credentials for live and test environments, with permissions matched to the work. Document credential ownership and use named accounts with limited access. Keep secrets in your approved runtime configuration or secrets manager. In team instructions and AI prompt templates, use placeholders for configuration names. Review service-specific limits such as approved origins, quotas, and the smallest set of accessible resources.
Connect secret scanning and prevention checks to the repository and release process where your provider and plan support them. Pair those automated checks with a review of what the build sends to browsers or mobile clients. A checklist for new integrations can include the owner, permitted actions, storage location, rotation method, and an agreed way to verify the production configuration.
For more context, read the vibe coding launch checklist, guide to app authentication and record access, and AI-generated code audit overview. Artemesis vibe code rescue can help scope fixes for the app paths that use the affected services.
See also the AI app security for permission and review decisions specific to model-powered features.
Frequently asked questions
Can I leave the old key active until the next release?
Decide with the incident owner and provider administrator. An exposed high-privilege key may need immediate revocation. If the provider supports a safe short transition, identify the people who can approve it, set an explicit limit, and confirm revocation.
Is an environment variable always private?
Privacy depends on where the value is available. A server runtime can keep approved secrets in a protected environment. Some build tools deliberately include selected environment variables in distributed client code. Verify which environment variables go into public builds.
Can a clean secret scan prove no credential was exposed?
A scan can reduce risk and find supported patterns. Review relevant builds and environments as well, and verify credentials and usage with the issuing provider when investigating a specific event.
What should I do if I pasted a real key into an AI chat?
Tell your organization’s security or service owner and follow the incident process. Identify what was pasted using safe metadata, determine who can see or retain the conversation, and make a prompt credential-rotation decision.
Should I rotate keys on a schedule?
Set a policy based on each provider and the consequences of the key’s access. Some systems offer short-lived credentials so manual rotation plays a smaller role. Make sure you have a tested way to change access immediately after exposure.
Ask Artemesis for help reviewing the affected app and describe which service it connects to and which workflows need to recover.
