aifree.dev

Why does a leaked API key get used within minutes?

API keys: bots scan every public push for keys and try them within minutes; replace a leaked key at once · Beginner · 5 min · safety, llm · after Rate limits (RPM, TPM, RPD), Free tiers: a busy GPU makes tokens for cents, and free buys customers, data or idle hours

An API key is your account’s password. Bots scan every public GitHub push, and in honeypot tests leaked keys were used within 2 to 5 minutes. Keep keys in environment variables, and replace a leaked key at once.

Before you start: could you explain this to a friend?

1 = not at all · 5 = easily

  1. 1 Guess first

    You push code with your API key to a public GitHub repo by mistake. How long until someone else uses it?
  2. An API key is a password that comes with your account. Whoever sends it is you: the calls use your free limit, or your money. Keys have a recognisable shape, so a program can scan any public text for them: commits, pastes, posts.

  3. 3 Look

    A leaked key, minute by minute

    1 / 5

    An API key is a password that comes with your account. Whoever sends it is you: the calls count against your free limit, or your bill.

    # .env (listed in .gitignore)
    GEMINI_API_KEY=<your key>

    Keys have a recognisable shape, so a program can find one in any text it reads: a commit, a paste, a screenshot’s caption.

    Google and GitHub docs, read 2026-10-26; no real key shown

    An API key is your account’s password. Keep it in an environment variable on your machine or server, never in the code you share.

    Get a key the safe way: free AI APIs with no credit card · sites that sell “shared” keys: scam list

    A public key is a used key: the scan takes seconds, and the bill is yours until you replace it.

  4. 4 You are the model

    Scanner bots read anything public. For five places a key can sit, say whether it stays private or is exposed.

    key 1 of 5 · can a scanner bot find it?

    In a .env file that .gitignore keeps out of the repo, read as an environment variable.

    Rules from Google’s and GitHub’s docs, read 2026-10-26

    You are the scanner bot’s target. Say where each key is safe.
  5. 5 Check

    You committed a key and removed it in the next commit, five minutes later. What now?
  6. If a key leaks, replace it first, then clean up. Google’s checklist: create a new key, deploy it, disable the old one, then check your usage. GitHub warns that deleting the commit does not remove the key from clones, forks or old commit links.

  7. 7 Say it back

  8. 8 Mission · 5 min

    Pick a free API with no card, create a key, and store it in a .env file listed in .gitignore. Then rehearse the leak drill once: create a second key, switch to it, and disable the first.

Three quick ones

Drawn at random from this lesson's pool; different next time.

Done?

Now: could you explain this to a friend?

1 = not at all · 5 = easily

Answer the three quick ones first.

Get an email when new lessons come out

New lessons arrive in the weekly digest, only in a week that has one. You confirm by email first; unsubscribe in one click.

Sources

  • Orca Security, “2023 Honeypotting in the Cloud Report” (2023-06-20, https://orca.security/resources/blog/2023-honeypotting-in-the-cloud-report/, checked 2026-10-26): research January to May 2023, honeypots on 9 kinds of cloud resources each holding an AWS key; “We saw key usage on GitHub within 2 minutes”; secrets on GitHub, HTTP and SSH found in under five minutes
  • Palo Alto Networks Unit 42, “EleKtra-Leak: Cloud-Based Cryptojacking Campaign Targeting AWS IAM Keys on GitHub” (2023-10-30, updated 2023-11-06, https://unit42.paloaltonetworks.com/malicious-operations-of-exposed-iam-keys-cryptojacking/, checked 2026-10-26): the actor detected and used exposed IAM credentials “within five minutes of their initial exposure on GitHub”; 474 miners seen from 2023-08-30 to 2023-10-06
  • GitHub blog, “GitHub found 39M secret leaks in 2024. Here’s what we’re doing to help” (2025-04-01, https://github.blog/security/application-security/next-evolution-github-advanced-security/, checked 2026-10-26): “more than 39 million secrets were leaked across GitHub in 2024 alone”; “Every minute GitHub blocks several secrets with push protection”
  • GitGuardian, “The State of Secrets Sprawl 2026” (2026-03-17, https://blog.gitguardian.com/the-state-of-secrets-sprawl-2026/, checked 2026-10-26): 28.65 million new hardcoded secrets in public GitHub commits in 2025, a 34% increase year over year; AI service secrets reached 1,275,105, up 81%; of valid secrets found in 2022, the January 2026 retest found the validity rate “still above 64%”
  • Sysdig, “LLMjacking: Stolen Cloud Credentials Used in New AI Attack” (2024-05-06, https://sysdig.com/blog/llmjacking-stolen-cloud-credentials-used-in-new-ai-attack/, checked 2026-10-26): attackers resell LLM access bought with stolen cloud credentials; worst case Claude 2.x at quota, “(500K tokens/1000 * $0.016) * 60 minutes * 24 hours * 4 regions = $46,080 / day”, “the cost to the victim can be over $46,000 per day”
  • Google, “Using Gemini API keys” (https://ai.google.dev/gemini-api/docs/api-key, last updated 2026-10-06, checked 2026-10-26): “Never check API keys into source control systems like Git”; “Do not hardcode API keys directly in web or mobile apps”, use a backend; “Read keys from environment variables”, `GEMINI_API_KEY`; leak response checklist: create a replacement key, deploy, disable the old key once the new one is verified (“Do not delete the old key until the new key is fully active”), review billing and API usage
  • GitHub Docs, “Removing sensitive data from a repository” (https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository, checked 2026-10-26): “as a first step you need to revoke and/or rotate that secret”; after rewriting history, commits may still be accessible “In any clones or forks of your repository”, “Directly via their SHA-1 hashes in cached views on GitHub” and “Through any pull requests that reference them”
  • GitHub Docs, “About secret scanning for partners” (https://docs.github.com/en/code-security/secret-scanning/introduction/about-secret-scanning-for-partners, checked 2026-10-26): GitHub scans public repositories and public npm packages and “alerts the relevant service provider whenever a secret is detected in a commit”; the provider decides whether to revoke it, issue a new one or contact you. “Supported secret scanning patterns” (https://docs.github.com/en/code-security/secret-scanning/introduction/supported-secret-scanning-patterns, checked 2026-10-26): OpenAI, Anthropic, Google, Groq and Hugging Face keys are partner patterns
  • The five places in the scanner-bot step are illustrative; each answer follows the Google and GitHub rules above

Published Oct 26, 2026 · updated Oct 26, 2026

Embed this

Paste this into a blog post or course page: the lesson's main picture in an iframe, with a link back to the full lesson.

<iframe src="https://aifree.dev/embed/explain/api-keys" width="100%" height="620" style="border:0;max-width:720px" title="Why does a leaked API key get used within minutes? (aifree.dev Explain)" loading="lazy"></iframe>
<p><a href="https://aifree.dev/explain/api-keys">Why does a leaked API key get used within minutes? Interactive lesson on aifree.dev</a></p>

Never miss new offers and news

New tools, credits, and AI news are added regularly. Pick how you want to hear about them.

Telegram channel
Join @aifree_dev and get new free AI offers and news right in your Telegram feed.
Browser notifications
Turn on push notifications and get an alert on this device whenever something new is posted. No account needed.
Email newsletter
A weekly digest of new, changed and expiring free AI offers. Double opt-in, one-click unsubscribe. See the latest issue.

Unsubscribe anytime. Privacy

Frequently asked questions

What is aifree.dev?

aifree.dev helps everyone access AI through a curated directory of free AI tools, API credits, free tiers, and startup programs for coding, image, voice, video, and students - verified regularly.

How are offers presented?

Each offer includes its access details, free models when available, and expiration information when provided. Limited-time deals stay visible so they are easy to compare.

Do education and startup programs need verification?

Yes. Providers usually ask students to verify their status with a school email, student ID, or a program like the GitHub Student Pack, and ask startups to verify company details such as age, funding, or website. Check each offer’s claim page for the exact requirements.

What kinds of free AI offers are listed?

Free tiers and free trials from AI providers, free API credits, startup and student programs, and free tools for coding, image generation, voice, and video.

How can I suggest a tool or report a broken link?

Use the submit form: paste the offer page URL and a short note. A person checks every submission before anything is listed. Broken links and changed terms go through the same form.

+

Know a good one?

Tell us about an AI tool worth knowing. Found a broken link? We want to hear that too.

Submit an offer