AI security: secrets, .env files and access rights for coding agents

Contents
Threat model in one paragraph
How aredel splits secrets today
What can go wrong
Access rights that contain the blast radius
Secret hygiene that survives AI
Catch leaks before commit
Risk checklist for this repo

Threat model in one paragraph

An AI coding agent runs shell commands with your authority and reads your files into its context. Everything it reads — including secrets — then flows into tool output, session transcripts, filesystem snapshots, debug logs, shared links and exported sessions, and on free tiers possibly into model training. Security with AI assistants is therefore two disciplines: keep secrets out of the agent context in the first place, and give each agent only the access rights its role needs, as in Creating and developing agents and Three models, one project.

How aredel splits secrets today

This repo already separates non-secret config from real secrets. Both files below are tracked in git deliberately; the password lives nowhere near them:

container/tools/deploy/ ├── site.env ├── site.env.example ├── deploy-ftp.sh └── DEPLOY_FTP.md ~/.config/aredel/ └── ftp-creds.env

container/tools/deploy/site.env

~/.config/aredel/ftp-creds.env

Rules this setup follows, verified in the repo:

What can go wrong

Access rights that contain the blast radius

Default-deny posture for OpenCode, from the live trio config in this repo root. Global rules first, per-role exceptions after — last match wins:

{ "$schema": "https://opencode.ai/config.json", "permissions": [ { "action": "shell", "resource": "*", "effect": "ask" }, { "action": "shell", "resource": "git push *", "effect": "deny" }, { "action": "shell", "resource": "sudo *", "effect": "deny" }, { "action": "read", "resource": "*.env", "effect": "deny" }, { "action": "read", "resource": "*creds*", "effect": "deny" } ] }

Roles from Four complete agents, tightened for secrets:

AgentRead .envEditShellWhy
triage on Spark FreedenydenydenyFree tier must never touch secrets at all
builder on Lunadenyallowask, tests pre-allowedBuilds code, never deploys, never reads creds
reviewer on Opus 5.5denydenydenyJudges diffs; findings reference secret handling without quoting values

Deploy questions go to a human running deploy-ftp.sh, not to an agent with creds-file access. Team-wide blocks that projects cannot override belong in policies, not permissions — for example a global deny on tool.use shell:sudo *. Review sticky Allow always rules quarterly and delete the ones nobody can justify.

Secret hygiene that survives AI

Catch leaks before commit

Honest gap: this repo has no secret-scanning pre-commit hook today — php -l, PHPCS and reflow gates check code, not credentials. Until one lands, the manual gate is a staged-diff grep for the known shapes before every commit:

git diff --cached | grep -n -i "FTP_PASSWORD\|API_KEY\|BEGIN.*PRIVATE KEY" | grep -v "example\|TEMPLATE\|secret-here"

Review every hit by hand: placeholders in *.example files are fine, values are not. The durable fix is a scanner hook (gitleaks or equivalent) added to .pre-commit-config.yaml — tracked as follow-up work, not as an excuse to skip the manual grep now.

Risk checklist for this repo

RiskStatus in aredelAction
Secrets in tracked filesSplit done, deploy script warnsKeep the split; run the staged-diff grep
Agent reads creds fileDenied in root config for all rolesVerify with opencode debug config
Free-tier training leakTriage denies edits, shell and all but map skillNever route creds tasks to Spark Free
Prompt injection via toolsShell asks by defaultKeep it ask; never Allow always on shell
Pre-commit secret scanMissingManual grep now, scanner hook next
Key blast radiusOutside-repo creds, one deploy purposeSeparate keys per new purpose

Official sources:

Article author: Arthur Isaev

Related articles
AI
AI security: secrets and access rights
Creating and developing agents
OpenCode coding agent
Writing skills for AI assistants
MCP: give AI assistants real tools

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: