Securing your AI work: from first chat to what you ship
The more you use AI, the more places something can leak or break. These are the checks to run at each level, from typing into a chat to shipping an AI feature, and one thing to do today at each one. Find your level and stop there, or keep going.
The more work runs through AI, the greater the risk and the bigger the blast radius. One pasted document, one shared link or one approved package now reaches further than it used to, and even slips that never leak anything still turn into follow-up work, new standards and training.
There are two sides to this, and most people only think about one of them. The first is using AI safely yourself: what you paste in, what you share, and what you let it touch on your machine. That applies whether you're building apps or just making a deck. The second is protecting what you build from people outside who go looking for a way in. This post is split the same way.
It doesn't cover every security issue; that would be a book, not a post. It covers the areas that carry the most risk, with checks you can actually run.
Each level has the same four parts: what can go wrong, the checks, what to use, and one thing to do today.
Part AUsing AI safely
Talking to AI
What can go wrong
Most of the risk here is what you hand over. Customer names, emails, contracts, someone's CV, an internal strategy doc. Once it's in a chat it's in someone else's system, and depending on the tool and your settings it may be kept, used for training, or readable by connectors you switched on months ago and forgot about.
The checks
- Is this tool approved for this kind of data? Work data goes into the tools work has approved, not whichever one is open.
- Does anything here identify a person or a client? If so, take it out or replace it before it goes in (names to roles, real numbers to rough ones).
- Are the privacy settings checked: are chats used for training, how long are they kept, what does memory store?
- Which connectors are on, and what can each one read? A connector to your email or drive means the AI can read that too.
What to use
A simple rule: personal information and secrets like private keys never go in. Where something has people or sensitive details in it, leave that part out and paste only what the AI actually needs.
Making things with AI
What can go wrong
AI makes it very quick to publish something, and that's where small things slip through. A "private" link that anyone with the URL can open. A client's name in a proposal when the contract says it can't be used. A file you share that still has your own notes, a folder path or someone's name buried inside it. Or something that copies another company's material or look a bit too closely.
The checks
- Who can open this? Check the share setting itself, not what you think it is.
- Does anything here breach the contract or create a liability, like a client name you're not allowed to use?
- Read the whole thing as the person receiving it would, including speaker notes, hidden slides, comments and file names.
- Search for leftovers: "lorem", "TODO", "test", "example.com", your own name, client names, file paths.
What to use
Match the check to what you're making. For documents and proposals, make sure nothing that goes out breaches the contract or creates a liability: if a client doesn't allow their name to be used, it doesn't go in. Avoid personal information altogether and use pseudonyms. If a product genuinely needs user data, it moves into level 4: the code has to be safe and reliable, and the back end set up to security best practice.
Letting AI work on your machine
What can go wrong
Once an AI agent can read files and run commands, it can also read the files you'd never paste into a chat: the .env file with your API keys, your SSH keys, your cloud credentials. It can run a command that deletes something, and it can install a package that does far more than it says. Packages are the part most people underestimate. The AI suggests one, you say yes, and its install script runs on your machine before you've looked at it. AI can also suggest a package name that doesn't exist, and attackers register those names so the next person to accept the suggestion gets theirs.
The checks
- Can the AI read your secrets? It shouldn't be able to, and a rule in the tool's settings is more reliable than asking it nicely in a prompt.
- Which commands must always ask first? Deleting files, pushing code, deploying, anything that spends money.
- Before installing a package: is it the real one (check the spelling character by character against the docs you got it from), is it maintained, who publishes it, and does it run scripts on install?
- Is the lockfile committed, so the same versions install every time?
- Skills and plugins for your AI are packages too. Before installing one, read its SKILL.md and check its security audit. When Snyk scanned 3,984 public agent skills in February, it confirmed 76 with malicious payloads. Vercel's skills.sh directory now shows audits from Snyk, Socket and Gen on each skill page.
What to use
Build a few rules into the project template every app starts from, so the agent follows them without anyone having to remember:
-
It always confirms before anything destructive, like deleting files, deleting branches or
git reset --hard. -
Before every
git pushit checks the files going out for.env,*.keyand*.pemfiles and for hardcoded keys, tokens and passwords, and stops to ask if it finds one. -
After adding any package it runs
npm audit, and high or critical issues get fixed straight away.
For new packages, a small pre-install script does most of the work. It checks the package actually exists on the npm registry (a typo or a made-up name stops there), shows the weekly downloads and asks for confirmation if it's under 10,000, prompts a check of the official listing and GitHub repo and that the name isn't a misspelling, then installs with --ignore-scripts and runs npm audit afterwards. Existing on the registry doesn't prove much on its own, because a typosquat is a published package too, so the manual check still matters. Treat a skill copied from someone else the same way: pin it, and read the diff when it updates, because functionally it's code your agent will follow.
To stop the AI reading secret files at all, block them in the tool's own settings so the rule applies to every project. In Claude Code that goes in ~/.claude/settings.json:
{
"permissions": {
"deny": [
"Bash(env)",
"Bash(env:*)",
"Bash(printenv)",
"Bash(printenv:*)",
"Read(**/.env)",
"Read(**/.env.*)",
"Read(~/.ssh/**)",
"Read(~/.aws/**)"
]
}
}In Codex it's a permissions profile in ~/.codex/config.toml (permission profiles are still marked beta, and they don't mix with the older sandbox_mode setting):
default_permissions = "protect-secrets"
[permissions.protect-secrets]
extends = ":workspace"
[permissions.protect-secrets.filesystem.":workspace_roots"]
"**/.env" = "deny"
"**/.env.*" = "deny"
"**/*.env" = "deny"
[permissions.protect-secrets.filesystem]
"~/.ssh" = "deny"
"~/.aws" = "deny"One limit to know: in Claude Code these rules cover its own file tools and common commands like cat, but not a script that opens the file itself. For that gap the docs point to the sandbox, which blocks file and network access at the operating-system level.
Part BProtecting what you build
Apps you build with AI
What can go wrong
AI is very good at making an app that works and much less reliable at making one that's locked. The common gaps are keys sitting in front-end code where anyone can view them, databases where any logged-in user (or anyone with the app's public key) can read every row, and forms that trust whatever is typed into them.
The checks
- Secrets live on the server or in environment variables, never in front-end code and never in git history.
- Every table has access rules: who can read this row, and who can change it? (In Supabase, that's row-level security, and it should be on for every table.)
- Never trust an ID, role or price sent from the browser. Work out who the user is from their session on the server.
- Everything that comes in from a user is checked on the server, and nothing user-supplied is put straight into HTML, a URL or SQL.
What to use
Decide how much protection the app needs before any controls go in. Four questions set it: who the users are, what data is stored, what regulations apply, and how bad a breach would be. The answers set a tier, from internal tool to high-risk, so a small internal tool doesn't get over-hardened and a public app with personal data doesn't get under-protected. From there, ordinary reads are protected by database rules, anything privileged is checked on the server, and the agent is told never to use eval(), innerHTML or dangerouslySetInnerHTML. Then before a release, or on any change to auth, payments or data, run a security review as a separate reader. It should only report and never edit, because a reviewer that can patch what it finds starts defending its own work.
Here's what "every table has access rules" looks like in Supabase, on an example notes table where people should only see and change their own notes:
alter table notes enable row level security;
create policy "Read own notes" on notes
for select using ((select auth.uid()) = user_id);
create policy "Change own notes" on notes
for update using ((select auth.uid()) = user_id)
with check ((select auth.uid()) = user_id);With row-level security on and no policy for a type of access, the answer is no, which is the default you want.
AI inside your product
What can go wrong
When you put a model inside your product, anything it reads can try to give it instructions. That's prompt injection, and it can come straight from a user or hidden in content the model reads, like an email, a web page or an uploaded file. For example, a support assistant that reads incoming emails could get one with a hidden line asking it to forward the last ten invoices to an outside address. It's number one on the OWASP Top 10 for LLM Applications, which is the list most teams use as the standard. The 2026 edition came out in August, and the top three are prompt injection, sensitive information disclosure, and excessive agency (a model given more power to act than it needs). Excessive agency moved up to third, a clear sign of where things are heading as models are given more tools.
The checks
- Treat anything the model reads as if it came from a stranger, because it might have. Tool results, fetched pages, uploaded files and rows another user wrote all count.
- Separate deciding from doing. Don't let one step both read untrusted content and take a privileged action on it. Read it, check the result in code, then act.
- Never run model output directly as code, a database query or a command, and never show it as trusted HTML.
- Give each tool the narrowest access its job needs, read-only by default. A tool that summarises tickets doesn't need to close them.
- Anything hard to undo (deleting, changing permissions, sending messages, payments, bulk exports) needs a human yes.
- Keep secrets and other people's data out of prompts.
What to use
The checks above are the core rules; write them into the instructions your AI coding tools follow, so every feature starts from them. For anything beyond them, the OWASP list is the place to start.
The pipeline that catches what you miss
What can go wrong
Everything above relies on someone remembering. The pipeline is there for the day they don't. Without it, a key gets committed, a vulnerable package gets merged, or a change nobody really reviewed goes straight to production.
The checks
- Every change gets a review, and an AI reviewer is a second pair of eyes, not the only pair.
- CI runs a dependency check (
npm auditorcomposer audit), secret scanning and the tests. - The deeper security review happens where it matters, before a release and on sensitive changes.
- A named person signs off before anything is deployed.
What to use
Dependabot watches the dependencies and opens a pull request when one has a known flaw. GitHub's Copilot review reads pull requests. Anthropic's security review comes in two forms: the /security-review command in Claude Code before a commit, and the GitHub Action on pull requests. Anthropic's own README says the Action isn't hardened against prompt injection and should only review pull requests you trust, which is level 5 showing up in your own pipeline. Keep the deepest review off the everyday path on purpose: a review that runs on everything gets skimmed on everything, so save it for releases and for changes to auth, payments or data.
As an example of how the layers split the work: Dependabot flags a package with a known flaw, the AI reviewer flags a new endpoint that doesn't check who's calling it, and the deeper review before release finds that a background job can still reach the same data without that check.
Staying current
This one runs across every level. The software you build on keeps having flaws found in it, and that's normal. The risk is in the gap between a flaw going public and you patching it, because that's exactly when attackers go looking for anyone who hasn't.
October was a good example. On 21 October Node.js shipped security releases for every supported line, fixing four high-severity flaws, one of which could let an attacker run code on a server that unpacks compressed data they send. The same day, PHP shipped fixes for two critical flaws (nicknamed PHP2Shell) that could let an attacker run code on a server, after details had already leaked the day before. And a few days earlier, eMudhra, a certificate authority, found that a script error had given eight of its certificates weak keys that nobody noticed for about 18 months, through two audits. That last one isn't about AI, but it's a good reminder that anything a script generates for you is worth checking too.
The checks
- Do you know what versions you're running (Node, PHP, frameworks), and are they still supported?
- Where will you hear about a new advisory? The official security release pages and GitHub security advisories, with dependency alerts on the repo.
- How fast do you patch? Critical flaws in something internet-facing should be days, not "next sprint".
- Before installing anything new, especially something an AI suggested, the package checks from level 3.
What to use
Tech blogs, X, colleagues and partners often surface an issue first. Dependabot covers the dependencies in your repos.
The checklist to copy
Sources
- OWASP GenAI Security Project, Top 10 for LLM Applications 2026 (Aug 2026), with the ranked entries in the project's source repository
- Atlassian Developer, axios npm supply chain compromise (compromise window about 00:21–03:15 UTC, 31 Mar 2026)
- Node.js, October 2026 security releases (21 Oct 2026)
- IPA, PHP security alert (21–22 Oct 2026)
- BleepingComputer, PHP warns admins of two critical flaws (20 Oct 2026)
- BleepingComputer, Mozilla, Google, Apple block compromised eMudhra CA certificates (20 Oct 2026)
- Snyk, ToxicSkills: malicious AI agent skills (Feb 2026) and skills.sh, About
- Claude Code docs, Configure permissions
- OpenAI Codex docs, Permissions
- npm docs, config: min-release-age, ignore-scripts
- Anthropic, Automate security reviews with Claude Code and the security review GitHub Action