Sovereign-Computing.com

Reclaim your digital life. Own your sovereignty.

New deadbolt on a front door while a side door is propped open with a brick: the lock on the address, not the program.

The Locked Front Door and the Open Side Door

Last month I spent a whole evening putting a proper lock on one page of my homelab. The next evening I found that the program behind that page had never been locked at all. This piece is about the difference between protecting an address and protecting the thing that answers at it. It is also, if I am honest, about how good it felt to be wrong in such an instructive way.

The page is a small dashboard. It lists every machine on my private network, with its name, its address, and when it was last seen. Nothing dramatic. You build something like it when you have 12 machines and no memory. The alternative is a text file that goes stale in a fortnight.

Two locks, and a third thing I mistook for a lock

I gave that page two locks, and I tested both of them, which at the time felt like diligence.

The first lock was network position. The page answers only to devices on my own network, or over my private tunnel when I am away from the house. Anything arriving from the open internet gets nothing at all. The second lock was a sign-in gate that sits in front of the page and asks for a password and a six-digit code from an app on my phone. Two independent locks, applied by two different pieces of software, each tested on its own.

There is an implicit third lock that people like me believe in without ever saying it out loud. It is the belief that my private network is private. That belief is doing a lot of quiet work, and it deserves to be examined rather than assumed.

Home networks are almost always flat. Your laptop, your phone, the television, the smart plug, the doorbell and the games console your nephew left logged in are all on the same network. So is the machine running your backups. By default every one of them can talk to every other one. That is fine when they all belong to you and all behave. It stops being fine the moment one of them is a cheap device from a company that stopped shipping firmware updates in 2023. The moment such a device is compromised, the attacker is not outside your network looking in. The attacker is inside it, and on a flat network that is the same thing as being you.

So “only my network can reach it” is a real lock, but it is a lock that trusts every object on the network. That is a lot of trust to hand to a doorbell.

Then I asked the program directly

The next evening I did the obvious thing, the thing I should have done before I wrote a single rule. From another machine on the same network, I did not ask the web server for the page. I asked the program itself, on its own port, for its status.

It answered immediately.

No sign-in. No six-digit code. No allow-list, because the allow-list lived in the web server and I had not gone through the web server. It handed over the whole device list: six machines, their names, their addresses, and when each of them was last seen. If you were burglary-minded, it was the most useful page in the house.

I had locked the front door and left the side door open with a brick holding it.

Why the gate did not apply

The gate lives in the web server. It runs when a request arrives at the web server, and it decides whether that request gets through. The dashboard, however, is its own program. It listens on its own port and answers whoever asks. When I curled that port from another machine, the web server was never in the conversation. There was nothing to consult a rule, so no rule applied.

The plain version is this. I had put a lock on the front door of a building that also had a back door opening onto the same car park.

That is the whole accident, and it is worth sitting with because it is not an exotic one. A gate is only real if the thing you are protecting can only be reached through it. If the same program will also answer on its own port, the gate protects the address and not the program. Anyone who knows the second address, or who is willing to scan for it, walks past the gate without ever meeting it.

The fix, and the part that matters more than the fix

The fix itself is dull, which is usually how you can tell it is correct. I put firewall rules on the machine that runs the dashboard. Only the gateway is allowed to reach the program’s own ports. Everything else is dropped, and dropped silently, because a polite refusal is an invitation to keep trying.

The part that matters more than the fix is persistence. A rule typed by hand at 11 at night is a rule you are going to lose the next time that machine reboots, patches, or gets rebuilt. And the rebuild is exactly the moment you will forget. So the rules went into the machine’s own saved configuration, and the service that loads them was enabled at boot, so that a restart cannot quietly reopen the door.

Then I proved it by consequence rather than by reading my own config file back to myself. A config file that says the right thing and a network that behaves the right way are two different claims:

  • From another machine on the network, direct access to the program is now dead on both of its ports.
  • Through the gateway, the page still answers, and the gated paths still bounce me to the sign-in.
  • The private directory that lists my services still loads.
  • Remote shell access to that machine was not touched at all, because locking yourself out of your own repair route is a second incident, not a fix.

The harder case: a gate in the right place, and a client that cannot satisfy it

A fortnight later I met the same problem wearing better clothes.

This time the application was behind the sign-in gate properly, on every human-facing path. But the application’s own interface calls a small programming interface in the background. Those calls are made by the browser in a way that does not reliably carry the sign-in cookie. So the gate answered those calls with a redirect, and the application reported the only thing it could report, which was that it could not connect.

The tempting repair is to switch the gate off and call the network position good enough. I have made that trade before and regretted it. The better repair was to stop treating the application as one thing and place the gate per path:

  • The shell of the application, and every path a person clicks, stays behind the password and the code.
  • The small programming interface sits behind the network allow-list plus the application’s own long random password, which the client sends on every single call.

Then prove all three states rather than assuming them. With the password the interface answers 200. Without it, 401. And the shell, with no session, still redirects to the sign-in. Three measurements, and the gate is better than it was before, not worse.

The rule that generalises: when a client has a legitimate reason to call a program directly, give that one path its own lock. Do not remove the lock for everybody because one caller cannot use it.

One small trap that is worth knowing

A redirect is answered before the gate runs. The web server decides to move you to the trailing-slash version of an address at an earlier stage of its work than the stage where it checks your credentials. So if you put the gate on the bare address, it is never consulted, and you can keep a gate there for years while it refuses nobody.

In my case that was harmless, because there is nothing to see at the bare address and the real path was gated. But it is a useful reminder that the order in which the web server does things is part of your security model whether or not you have thought about it. You can write a rule that is correct, save it, reload the service, watch it report success, and still have protected nothing.

If you run this at home, here is the short list

  1. List everything that is listening on a port, on every machine you own. Ask the machine itself rather than your memory of it.
  2. For each one, ask the only question that matters: what else can reach this thing directly, without going through whatever I think is protecting it?
  3. Test from a second machine. Testing from the machine itself proves almost nothing, and it is how the side door stayed invisible for a week.
  4. Persist your rules and enable them at boot, because you will not remember them in six months.
  5. Re-test after every rebuild, not just after the change.
  6. Treat “it has a login page” as a claim rather than a fact, and go and check what the program does when you skip the page.

Where this leaves me

The lock on the front door was a good lock. It is still a good lock, and I would fit it again. The mistake was believing that because I could see it, and had tested it, it was the only way in.

That is the shape of most home security failures, and not just in computing. You defend the door you thought of. The thing that gets you is the door you installed yourself, forgot about, and left open because nothing bad had happened yet.

On a home network, those forgotten doors all have names and ports, and every one of them is one honest inventory away from being found.

WordPress Appliance - Powered by TurnKey Linux