On this page
Key takeaways
- A secret that was ever committed is leaked, even if you deleted it later.
- Assistants often check the login in the screen but not in the API route behind it.
- A copy on the same disk is lost together with it.
An assistant can produce a working app in an afternoon. Working is not the same as ready for the public internet: the code that runs on your laptop was written to run on your laptop. Before you put the project on a server, run these twelve checks. Each one has a command and the answer you should get.
Before you start
Some commands run in the project folder on your computer, some on the server. Replace SERVER_IP with the address of the server and YOUR_DOMAIN with the address of your app; PRIVATE_PATH stands for a route that returns personal data. Run the checks that send many requests only against your own app.
- the project in a git repository
- a server you control, with the first-hour setup done
- for the checks from outside: the app running on the server, with a domain that points at it
The steps
No secret file is in git
An assistant often creates a .env file for keys and does not always keep it out of git. The first command lists tracked files that look like .env files, apart from a .env.example with fake values: expect no output. The second shows which ignore rule covers .env: expect one line.
git ls-files | grep -E '(^|/)\.env' | grep -v '\.example$'
git check-ignore -v .envNo secret is typed into the code or the history
The first command looks for assignments such as api_key, secret, token or password with a long value: expect no output, or only harmless test values. The second asks whether a .env file was ever committed: expect no output. A secret that was ever committed is leaked, even if you deleted it later.
git grep -n -I -i -E '(api_key|secret|token|password) *[:=] *.[A-Za-z0-9_-]{16,}'
git log --all --oneline -- .envDeleting a leaked key from git is not enough. Create a new key at the provider and revoke the old one.
The app runs in production mode
Development servers show stack traces, reload on every change and are not built for traffic. Start the app with the production command of your framework, for example npm run build and then npm start. On the server, expect no output from the check.
pgrep -af 'next dev|vite|flask run|runserver|nodemon'The database accepts connections from the app only
The first command, on the server, lists database ports that are listening. Expect nothing, or only addresses that start with 127.0.0.1. The second runs on your computer: expect it to be refused or to time out. Open databases are scanned for all the time.
sudo ss -ltn | grep -E ':(5432|3306|27017|6379)\s'nc -vz -w 3 SERVER_IP 5432Plain HTTP redirects to HTTPS
Expect 301 or 308 with a location starting with https:// from the first command and a normal answer from the second. A certificate error means HTTPS is not set up yet: put a reverse proxy such as Caddy in front of the app, as the n8n guide does.
curl -sI http://YOUR_DOMAIN | head -n 3
curl -sI https://YOUR_DOMAIN | head -n 3Private routes refuse anonymous requests
Assistants often check the login in the screen but not in the API route behind it. Take three routes that return personal data or change something and call them without logging in. Expect 401 or 403, not 200. If your app has users, also log in as one user and ask for an object of another: the answer must be 403 or 404.
curl -s -o /dev/null -w '%{http_code}\n' https://YOUR_DOMAIN/api/PRIVATE_PATHOther websites cannot read private answers
Expect no output, or an Access-Control-Allow-Origin that names your own front end. If the response repeats https://other.example, the app trusts every website, and a visitor’s browser may let any page read their data. The value * together with credentials is just as bad.
curl -s -D - -o /dev/null -H 'Origin: https://other.example' https://YOUR_DOMAIN/api/PRIVATE_PATH | grep -i '^access-control'Login and expensive routes have a limit
Expect the codes to change to 429 after some attempts. If you see 401 thirty times, anyone can try passwords at full speed. The same goes for routes that call a paid service such as a model API: without a limit, one visitor can run up your bill. Change the path and the field names to match your login route.
for i in $(seq 1 30); do curl -s -o /dev/null -w '%{http_code} ' -X POST https://YOUR_DOMAIN/api/login -d 'email=test@example.com'; done; echoRun this only against your own app.
Dependencies have no known serious holes
npm audit lists known problems in what you ship; for Python use pip-audit. A lockfile makes the server install the versions you tried. An assistant may also suggest a package name that does not exist or that belongs to someone else, so read the names you do not recognise before you install them.
npm audit --omit=dev
git ls-files | grep -E 'package-lock.json|pnpm-lock.yaml|yarn.lock|requirements.txt|poetry.lock'Errors do not show the inside of the app
Expect a short, plain error from both commands. A stack trace, a file path or an SQL statement tells an attacker how your app is built. If you see one, turn off detailed errors in production and log them on the server instead.
curl -s https://YOUR_DOMAIN/this-page-does-not-exist | head -c 400
curl -s -X POST https://YOUR_DOMAIN/api/PRIVATE_PATH -H 'Content-Type: application/json' -d '{' | head -c 400The app comes back after a restart
Expect unless-stopped or always for a container, and enabled for a systemd service. The real test is a reboot at a time you choose: afterwards the app must answer without you. The Docker guide and the automatic-updates guide show how.
sudo docker inspect -f '{{.HostConfig.RestartPolicy.Name}}' CONTAINER_NAME
systemctl is-enabled SERVICE_NAMEThe data is backed up and the copy can be restored
The example is for PostgreSQL in Docker Compose. Replace db, APP_USER and APP_DB with the names in your compose file. It dumps the database, restores the dump into a scratch database and removes that again. Then move backup.sql off the server. A copy on the same disk is lost together with it. Files that users upload need the same treatment.
sudo docker compose exec -T db pg_dump -U APP_USER APP_DB > backup.sql
ls -lh backup.sql
sudo docker compose exec -T db createdb -U APP_USER scratch
sudo docker compose exec -T db psql -U APP_USER -d scratch < backup.sql | tail -n 3
sudo docker compose exec -T db dropdb -U APP_USER scratchLet a second assistant review the first one’s work, read-only
A reviewer that did not write the code is more likely to notice what the author left out. The prompt below asks an assistant to run the twelve checks and report; it may not change anything. Give it a key that you can remove afterwards, and read the list of commands before you answer yes.
Do not paste real secrets into the chat. The prompt tells the assistant to show file names and line numbers, not values.
You are reviewing a project that another AI assistant built. The project folder is the current directory, the server is at SERVER_IP and the app is at YOUR_DOMAIN. Connect to the server over SSH as the user ops, which has sudo.
Rules:
1. Read-only. Do not edit files, commit, install, restart or change the server.
2. Before you start, show me a numbered list of the commands you will run and wait for my yes.
3. Run these twelve checks and report OK, a finding or not applicable, with evidence: secret files tracked by git; secrets in the code and the git history; development mode; database ports reachable from outside; HTTP to HTTPS redirect; private routes without login; CORS headers; a limit on the login route (send at most 30 requests, only to YOUR_DOMAIN); dependency audit; error pages that show internals; restart policy of the containers or services (do not reboot, only read the settings); backups (ask me how I restore them, do not guess).
4. Never print the value of a secret. Show the file and line number only.
At the end give a table: check, result, evidence, what I should fix first.Check the result
Checks 1, 2, 4 and 6 are the ones that end badly: a leaked secret, an open database or open routes. Fix those first; the others you can schedule. Run the list again after every larger change your assistant makes.
If something goes wrong
git ls-files shows .env.local
Remove it from the index without deleting the file: git rm --cached .env.local, add it to .gitignore and commit. If the repository was ever shared or public, treat every value in the file as leaked and replace it.
Everything returns 200, including the private route
The route has no check, or the check exists only in the page. Add the check in the route itself, on the server, and run check 6 again.
nc says the database port is open
Publish it on 127.0.0.1 only (in a compose file: 127.0.0.1:5432:5432) or not at all. Docker publishes around ufw, so the firewall does not save you here.
npm audit lists many problems
Start with the ones marked high or critical in packages you ship, not only use while developing. npm audit fix applies safe updates; read what it changes before you commit it.
Where to go next
The server underneath has its own checklist: twelve read-only checks for SSH, the firewall, open ports, updates and backups. To put the app on a server in the first place, start with the first-hour guide. Links are at the end of this page.
Runs Cloudvix and is responsible for the guides published here.