DEV Community

The app worked. Then I had to host it for strangers

For three months I had a workspace chat app that worked. Rooms, private rooms, direct messages, files, search, four roles, realtime. Probes attacked it from outside, and it passed every one.

Then I decided to put it on a public address and let people I do not know create accounts, and I found out how much of a product is not the product.

Nothing in the list below is a feature anybody asks for. All of it had to exist before the first stranger arrived.

A stranger can fill your disk

The app accepted ten files per message, twenty-five megabytes each, with no ceiling per workspace. Among colleagues that is generous. On a public server it is an invitation: one account, one script, and the disk is full by lunchtime.

So the first thing I wrote was not a feature but four numbers an operator can set:

  • megabytes per file
  • megabytes per workspace
  • people per workspace
  • workspaces per account

Then rate limits inside the app, because a reverse proxy can count requests per address but only the app knows that twenty messages in ten seconds from one account is a script, or that the fourth password reset in an hour for one inbox is harassment.

The rule I took from this: every resource a user can consume needs a number, and the number has to be yours to change without a deploy.

An account nobody can recover is not an account

The app had no email at all. Invites were links you sent yourself, which I had been rather proud of. It also meant a forgotten password was a lost account, and that nobody had ever proved an address was theirs.

Mail brought more decisions than code. A reset link built from the request's Host header can be pointed at an attacker's domain, so links are built from one configured address, and mail stays off until that address is set. Opening a confirmation link does not confirm anything, because mail scanners open links too; a button on the page does. And a server with no mail relay still needs a way back in, so the admin can create a reset link and hand it over.

Leaving has to work before arriving does

If you hold other people's conversations in the EU, those people can ask for a copy of what you hold and ask you to delete it. I would rather they never had to ask. An account can now export everything it wrote as one file and delete itself; an owner can export a workspace's rooms and close it.

Deletion turned out to be a design question. What happens to what a person said in a room other people still read? I kept the words and removed the name: a conversation with holes in it is everybody else's loss. And an account that is the only owner of a workspace with other people in it cannot simply vanish and leave them ownerless, so the deletion is refused until ownership is handed over.

Somebody has to be able to say no

A public instance needs a page only its operator sees. It shows who is here and what each workspace weighs, and it has three verbs: suspend, delete, close.

I made one decision early and kept it: that page counts messages and never shows one. Reading what people wrote takes database access, which an operator has anyway and should need a reason to use.

Four bugs that shipping found

The probes had been green for weeks. These four turned up only once I published the thing and installed it on a machine that was not mine.

  • The compose file would not start without a domain. A required variable inside an optional service is still read when the service is off. Every install without HTTPS failed on line one.
  • The installer left the secrets file readable by everyone on the machine. It set the right permissions, then rewrote the file, and a rewritten file is a new file.
  • The image could not be published after the repository was recreated. The package still belonged to a repository that no longer existed, and the new one was refused.
  • The probes themselves broke when the landing page became cacheable. They fetched it to obtain a CSRF token, and a page served from a shared cache mints none. The app was right; the tests had been leaning on an accident.

None of these is interesting. The first two would have been somebody's first five minutes with the project.

A backup you have not restored is a hope

The last item took the least code and the most nerve. I had a nightly dump. I did not know it worked until I deleted every workspace and every uploaded file on a test stack, restored both, and watched the app come back with the same rooms.

It did, the second time. The first attempt failed on a path, my mistake, which is exactly the kind of thing you want to learn on a quiet afternoon rather than during an incident.

What I would tell myself in September

The app was perhaps two thirds of the work. The rest was limits, mail, exits, an operator's page, an installer and a restore, and none of it shows in a screenshot. If you are about to open something you built to people you have not met, write that list before you write the announcement.

The app is called piazza. It is open source, it installs with one command, and there is a public instance at piazza.luigimicca.com if you want to see what the list above looks like when it is done. The source is on GitHub. Originally published on luigimicca.com.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.