[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"blog-least-privilege":3},{"slug":4,"title":5,"excerpt":6,"date":7,"readingMinutes":8,"cover":9,"coverAlt":10,"preview":11,"tags":16,"body":17,"caseStudies":18},"least-privilege","Least privilege: secure access without slowing developers down","Least privilege, applied painlessly: give every person, server and API key only the access it needs, without slowing your team down.","2026-11-09",2,"\u002Fassets\u002F6ad6f5cf-ff2e-467e-a7c5-7ac0775f10ed?width=1280&quality=80&format=auto","Digital security is more and more vital as AI makes life easier for attackers. Image Philip Oroni",{"path":12,"alt":10,"width":13,"height":14,"type":15},"\u002Fassets\u002F6ad6f5cf-ff2e-467e-a7c5-7ac0775f10ed?width=1200&height=630&fit=cover&format=jpg&quality=80",1200,630,"image\u002Fjpeg",[],"\u003Cp>Every part of a system (a website, a server, a deploy pipeline, a person) should hold only the access it needs for its job, and nothing more. That way we can know that when something is compromised, and eventually something will be, the attacker will get very little to work with.\u003C\u002Fp>\u003Cp>Security practices can seem ridiculously finicky, and sometimes one wonders if they are worth it when the data we are protecting is something that doesn't even seem worth stealing. But we need to know how to keep all doors closed so they can never be used as tools to open other doors. And the trick is that if we apply the same thorough rules to every project, and get used to a CI workflow around these rules.\u003Cbr>These are things we want to understand clearly, both for peace of mind and also to know that we have picked a workflow that saves time without cutting corners.\u003C\u002Fp>\u003Cp>Ok enough philosophy. Here is what this post is getting at:\u003C\u002Fp>\u003Ch2>How it applies to a web app\u003C\u002Fh2>\u003Cp>Every web service that serves logged in users allows those users to create and change content of their own, whether that be cart contents, favorites or to-do lists.\u003C\u002Fp>\u003Cp>\u003Cbr>This means there will be requests that need to touch the database. Each request carries the user's own auth token, proving who they are. Behind the scenes, the server also talks to the backend server with its own service token, linked to a service user whose permissions should be limited to exactly what the task requires.\u003C\u002Fp>\u003Cp>The idea is that if a case of a stolen token arises, then the attacker will be able to do very little harm with that token. Most importantly, they won't be able to use it to escalate their access (by doing things like changing their user permissions or making new tokens), or move to other systems laterally ( something like what the \u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.acams.org\u002Fen\u002Fopinion\u002Fbinance-hack-compliance-story-four-lessons-financial-crime-teams\">Oct 2026 Binance hack\u003C\u002Fa> managed to do).\u003C\u002Fp>\u003Cp>It's kind of like access quarantine.\u003Cbr>As I mentioned in my \u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"\u002Fcase-study\u002Fcomputravel\">computravel case study\u003C\u002Fa> , limited permission becomes even more vital in the case of sites with public forms, as that makes the api endpoint more load bearing, as anyone can start hitting it with curl and seeing what they can poke or peek at.\u003C\u002Fp>\u003Ch2>Working fast and loose\u003C\u002Fh2>\u003Cp>When you're building fast, you tend to want to keep things 'safe' in the sense of the code not breaking, not in the sense of security. The last thing we feel like dealing with is finicky permission issues.\u003C\u002Fp>\u003Cp>So the easy setup is to give the website one all-powerful key to the database and trust the website's code to show only the right things.\u003C\u002Fp>\u003Cp>But we should never forget that because a frontend server is exposed to the internet, and because it runs a lot of third party code, the secrets that it knows should never be considered safe. For example there could be a compromised NPM package that will be able to read process.env and quietly send the token somewhere. Or a bug in a route that constitutes a vulnerability, allowing the token either to be stolen or to be abused for its database access without the token actually being stolen('confused deputy' attack).\u003C\u002Fp>\u003Cp>There is also always a chance that the token could leak to the browser somehow, which as we know is wide open for human or programmatic reading.\u003C\u002Fp>\u003Ch2>Who holds the admin key? The pipeline, not a person\u003C\u002Fh2>\u003Cp>Whenever we want to deploy a new feature, we need to prepare the production db by adding new tables or at least new fields to allow the new code that expects to find these fields or tables, to run.\u003C\u002Fp>\u003Cp>So the CI workflow therefore needs an admin token to be able to perform these migrations.\u003C\u002Fp>\u003Cp>A solution is for the admin key to live in one file on the production machine, read only by the deploy job and only while it runs.\u003C\u002Fp>\u003Cp>But whoever can get code deployed can run code with that key. So the real perimeter is what the production server will agree to run, and that's where the strongest protection belongs: for example, a server that deploys only commits on main signed by a trusted key. Developers then don't need production admin tokens at all, apart from a break-glass key kept for emergencies.\u003C\u002Fp>\u003Cp>What about the DB password? That is in fact a more powerful secret than the admin token and it also lives in the memory of a running server. But the database only accepts connections from the backend server, which means the DB password can't be used from anywhere else.\u003C\u002Fp>\u003Cp>So we could say that least privilege works in layers. Scoped tokens limit what the frontend server can do to the backend server. The database role and network rules limit what the backend server can do to the database. Each layer assumes the one above it might be compromised.\u003C\u002Fp>\u003Cp>I plan to write another post that goes into the way I set up Yearcrest's CI in a way that automatically updates the prod db in a sustainable way. I ended up with idempotent and once-off scripts, and a ledger table to keep track of which once-off scripts had been run.\u003C\u002Fp>\u003Ch2>Conclusion\u003C\u002Fh2>\u003Cp>It's a big load off to accept these risks and build CI workflows around them so that there are no more decisions to make about tokens. Because these risks are real and getting more real every day in this AI era, with attacks being cheaper and faster.\u003C\u002Fp>\u003Cp>And knowing that we have closed them off builds confidence and reduces stress. There is nothing better than being able to defend your security posture in any conversation (without prompting an agent!).\u003C\u002Fp>\u003Cp>The trick is to learn to be that person who thinks these things through properly, and also, gets things done without getting stuck in a tangle in the middle of deploying a new feature.\u003C\u002Fp>",[]]