Cehpoint

Free preview lesson ยท 25 min

Secrets in AI-assisted development

From the course Securing AI coding agents and vibe-coded apps.

Secrets in AI-assisted development

In this lesson you will learn where secrets leak when people build with AI coding assistants, how to keep them out of prompts, repositories and deployed sites, and what to do in the first hour after a leak.

What counts as a secret

A secret is any value that grants access: API keys, database passwords, cloud credentials, signing keys, webhook secrets, session-signing keys, SSH private keys, and the tokens of services such as payment or email providers. If someone else holds it, they can act as you.

AI-assisted development creates new ways for secrets to escape, because the assistant reads files, writes files, runs commands and sends text to a model. Each of those is a path.

Five places secrets leak

1. Into the prompt

People paste an error message, a config file or a .env file into the chat "so the assistant can see the problem". The secret has now left the computer and may sit in a conversation history. The Cehpoint operating guide for assistants makes this a rule in the other direction too: never ask the person to paste a key, token, password or .env content into the chat.

Habit: redact before you paste. Replace values with *** or a placeholder such as DATABASE_URL=<redacted>.

2. Into the repository

An assistant asked to "make it work" may hard-code a key into source code, or create a config file and commit it. Once pushed, the secret is in the history even if a later commit removes it.

Habit: keep secrets in environment variables or a secret store; list .env and similar files in .gitignore before the first commit; review every diff for anything that looks like a key.

3. Into front-end code

A browser downloads everything in your front-end bundle. A key placed in client-side JavaScript, or in a build variable that gets inlined into the bundle, is public, whatever the variable is called. Vibe-coded apps (apps built mostly by describing them to an AI assistant) often get this wrong, because "it worked when I tested it".

Habit: any secret call happens on the server. The browser talks to your server; your server holds the key.

4. Onto the live website

Deployments sometimes copy the whole project folder to the web root, including .env, the .git folder, SQL dumps or backup archives. Anyone who requests https://yoursite/.env gets your secrets.

Cehpoint Agentic SOC checks for this from the outside: once a day it tests the client's own domains for downloadable secret files such as .env, .git, SQL dumps and backups. A secret file anyone can download is a critical alert, because it means act now.

Habit: deploy a build output, not the project folder; configure the web server to refuse dot-files; check after every deployment.

5. Into logs and evidence

Command lines and logs often contain passwords and tokens, for example --password=... or a database URL with credentials. The Cehpoint agents mask secrets in command lines on the device before anything is sent, and the server masks them again before storing; evidence explanations mask them a third time. Your own application logs deserve the same care.

How the Cehpoint skill helps

The skill checks a project for files that look like leaked secrets. The check runs locally: the skill reports only the file paths and how many likely secrets each contains, never the values, and nothing about secrets is uploaded. It skips the package manifests it reads for the dependency check. Treat each hit as "look at this file now", not as proof.

Your first hour after a leak

The OWASP Secrets Management Cheat Sheet gives the order: revoke, rotate, then delete.

  1. Revoke the exposed credential immediately at its source (the provider's console, or for a Cehpoint key, API and AI agents then revoke).
  2. Rotate: create a new credential and put it where the old one was used, in the secret store or environment, not in code.
  3. Delete the exposed copy: from the code, the logs, the chat, the web root. Rewriting git history can remove a commit's secret, but it breaks links to that commit and copies may already exist elsewhere; revoking is what actually makes the old value useless.
  4. Find out who had access and whether the credential was used while exposed. Check the provider's logs; for a Cehpoint key, the activity log shows every action under the key's name.

Hands-on lab

Environment: Your own computer (local only)

  1. Create an empty folder and run git init in it.
  2. Create a file .env with a fake value: PAYMENT_API_KEY=fake_test_value_123.
  3. Run git status. Notice that .env is listed as untracked: one git add . would include it.
  4. Create .gitignore containing .env on its own line. Run git status again and confirm .env is no longer listed.
  5. Run git check-ignore -v .env and read which rule ignores it.
  6. Create app.js with the line const key = "fake_test_value_123"; and run git diff --no-index /dev/null app.js (or simply open the file). This is what a hard-coded secret looks like in a review.
  7. Write three lines for your team: where secrets live in your project, what goes in .gitignore, and who to tell if a key leaks.
  8. Delete the folder.

Summary

  • Secrets leak through prompts, repositories, front-end bundles, web roots and logs.
  • Redact before pasting; ignore .env before the first commit; keep secret calls on the server; deploy build output only.
  • The SOC checks your domains daily for downloadable secret files; the skill flags likely secret files locally, without uploading values.
  • After a leak: revoke, rotate, then delete, and check for misuse.

Sources