Skip to contentcloudvix
cloudvix
GuideDevelopers & AI

Your assistant built the app: twelve checks before you put it on a server

Denys DunaievskyiFounder, Cloudvix
  • 12 min read
  • Published
  • LevelIntermediate
Guides
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.

On your computerbash
git ls-files | grep -E '(^|/)\.env' | grep -v '\.example$'
git check-ignore -v .env

No 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.

On your computerbash
git grep -n -I -i -E '(api_key|secret|token|password) *[:=] *.[A-Za-z0-9_-]{16,}'
git log --all --oneline -- .env
Warning

Deleting 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.

On the serverbash
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.

On the serverbash
sudo ss -ltn | grep -E ':(5432|3306|27017|6379)\s'
On your computerbash
nc -vz -w 3 SERVER_IP 5432

Plain 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.

On your computerbash
curl -sI http://YOUR_DOMAIN | head -n 3
curl -sI https://YOUR_DOMAIN | head -n 3

Private 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.

On your computerbash
curl -s -o /dev/null -w '%{http_code}\n' https://YOUR_DOMAIN/api/PRIVATE_PATH

Other 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.

On your computerbash
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.

On your computerbash
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; echo
Warning

Run 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.

On your computerbash
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.

On your computerbash
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 400

The 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.

On the serverbash
sudo docker inspect -f '{{.HostConfig.RestartPolicy.Name}}' CONTAINER_NAME
systemctl is-enabled SERVICE_NAME

The 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.

On the serverbash
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 scratch

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.

About the author

Denys Dunaievskyi

Founder, Cloudvix

Runs Cloudvix and is responsible for the guides published here.

Related guides

Your server is a few clicks away.

Choose the plan and the system in one order form; the location too, when there is more than one.

Create server