{"canonical_url":"https://engineer.company/glossary/privilege/","content_markdown":"# Privilege\n\n## What it is\n\nA privilege is permission to do something a system otherwise forbids, held by a\nperson or by a running program because an authority decided it should have it:\nread another user's files, bind a port below 1024, create accounts, run a\ndatabase function. People speak of privileges in the plural, because a subject\nrarely holds just one, and of “privileged” and “unprivileged” accounts or\nprocesses to say which side of that line something sits on. NIST's glossary adds\nthe part that is easy to forget: privileges describe the authorised behaviour of\na subject, and they are defined by an authority and written down in policy or\nrules.\n\nThe word sits next to two others. Access control is the act of deciding each\nrequest; a privilege is one of the facts that decision consults about whoever is\nasking. A permission is usually the same idea seen from the resource's side: the\nfile says who may read it, and the reader holds the right to do so.\n\nOn Linux the word has a precise meaning. The capabilities(7) manual describes\nthe traditional Unix split: privileged processes, which run with an effective\nuser ID of 0 and are known as root, bypass all kernel permission checks, while\nevery other process is checked against its credentials. Since Linux 2.2 the\nkernel has divided root's power into separate units called capabilities, which\ncan be switched on and off one at a time, so a program that needs only to bind a\nlow port can be given `CAP_NET_BIND_SERVICE` and nothing else. The\ncredentials(7) page explains whose identity is being checked: the real user ID\nsays who owns a process, the effective user ID is what the kernel compares\nagainst permissions, and the saved set-user-ID lets a program set aside a raised\nidentity and pick it up again later.\n\nDatabases and organisations use the same word for their own grants. A database\nrole holds privileges on schemas, tables and functions. An administrator account\nholds privileges a staff account does not. The idea is identical at every level:\na right, granted on purpose, to cross a line that is otherwise closed.\n\n## Why it matters\n\nThe privileges a program holds are the size of the damage it can do once\nsomething goes wrong with it. That is the stated aim of capabilities: a program\nthat has been compromised does less harm with a narrow set of rights than the\nsame program running as root. A web server with a code execution bug and root\nprivilege hands the whole machine to whoever found the bug; the same bug in a\nprocess that can read its own directory and bind one port reaches very little.\n\nNIST writes this down as least privilege. Control AC-6 in SP 800-53 asks an\norganisation to allow only the accesses that users, and the processes acting for\nthem, need to do their assigned tasks. Its enhancements turn that into routine\nwork: administrators use an unprivileged account for everyday tasks such as\nemail, privileged accounts are restricted to the people who need them, the use\nof privileged functions is logged, and privileges are reviewed and removed when\nthe need for them can no longer be shown.\n\nThe defaults rarely start there. In systemd, a system service with no `User=`\nline runs as root, and `NoNewPrivileges=`, the setting that stops a service and\nits children from ever gaining more through `execve()`, is off unless someone\nturns it on. Database tools often connect as the owner of every table because\nthat is how the schema was created. New staff are often copied from an existing\ncolleague's account, rights and all. Each default is convenient on the first day\nand expensive on the day something is breached.\n\nThe trade-off is real. Narrowing privileges takes time, because someone has to\nfind out what a program actually does, and a set that is too narrow breaks\nthings at runtime rather than at install time. The decision a team faces is\nusually where to spend that time first: on anything that faces the internet, on\nanything holding data people would miss, and on the accounts that can change the\nother accounts. For a buyer or an auditor the useful question is simple and\ndirect: who and what holds administrator rights here, and why.\n\n## What it looks like in practice\n\nOn the company's own host,\n[thirteen unit files ran with the privileges the supervisor gives by default](/portfolio/cut-systemd-sandbox-exposure-on-every-unit/),\nwhich is most of them. Every unit template gained a privilege ceiling fixed at\nthe unit's own, a system-call filter, restricted address families, and memory\nthat is writable or executable but never both. The hardening score for the\ndead-man's switch went from 9.6 to 1.5, the git forge from 8.3 to 1.5, and the\ntwo backup units from 9.6 to 2.3 and 2.5. One directive turned out to be\nmisspelled in three templates, and the supervisor had been logging an unknown\nkey and starting the unit anyway, so every unit is now run through the\nsupervisor's own verifier during each converge. The page also records what the\nscore leaves out: a directive that breaks a unit does so at runtime.\n\nOn an application platform,\n[the API logs in to the database as a least-privilege role](/portfolio/hardened-the-application-with-nonce-based-csp/)\nthat can only EXECUTE the app functions, which run as SECURITY DEFINER with\nparameterised queries. Entitlements such as tier, role, organization and ship\nscoping are re-checked on the server on every request, and the gates in the\ninterface are treated as UX only.\n\nAcross one organisation,\n[identities and access were consolidated across M365, 1Password, Red Hat SSO and OKTA SSO](/portfolio/led-access-management-across-m365-and-sso/),\nleast privilege was enforced, and onboarding and offboarding were standardised so\nthat access was revoked promptly instead of lingering after someone moved on.\n\n## Where it goes wrong\n\n**A service runs as root because its unit says nothing.** The supervisor's\ndefault for a system service is root, so a unit without a `User=` line holds\nevery privilege the machine has. Give each service its own user, or let systemd\nallocate one with `DynamicUser=`, which creates a user when the unit starts and\nreleases it when the unit stops.\n\n**One capability turns out to be most of root.** `CAP_SYS_ADMIN` covers so many\noperations that its own manual calls it overloaded and “the new root”. A team\nthat grants it to unlock one feature has granted most of root. Look for the\nspecific capability the program needs, and keep the bounding set to that list:\n\n```ini\n[Service]\nUser=web\nNoNewPrivileges=yes\nCapabilityBoundingSet=CAP_NET_BIND_SERVICE\nAmbientCapabilities=CAP_NET_BIND_SERVICE\n```\n\nThose settings let a service running as an ordinary user bind port 80, and\nevery other capability is removed from its bounding set.\n\n**A process climbs above where it started.** A program running as an ordinary\nuser can still execute a set-user-ID binary or a file with capabilities attached,\nand the kernel raises its privileges for that run. Defenders recognise this as a\nprocess whose effective user ID differs from its real one. `NoNewPrivileges=yes`\ncloses that route for a service and every child it starts.\n\n**Rights pile up as people change jobs.** Someone moves teams and keeps the old\naccess alongside the new, and after a few years their account holds the union of\nevery role they ever had. AC-6 answers this with periodic review, and AC-2 with\naccount management tied to transfers and departures, so that a change of job is\nalso a change of access.\n\n**The application's own login can do everything.** When an API connects as the\nowner of the schema, a single injection flaw reaches every table. A login role\nthat can only call the functions the application uses turns the same flaw into a\nmuch smaller problem.\n\n## Further reading\n\n- [Privilege, in the NIST CSRC glossary](https://csrc.nist.gov/glossary/term/privilege)\n  — the CNSSI 4009 definition, with the note that an authority defines privileges.\n- [capabilities(7)](https://man7.org/linux/man-pages/man7/capabilities.7.html)\n  — how Linux splits root into separate capabilities and how threads carry them.\n- [credentials(7)](https://man7.org/linux/man-pages/man7/credentials.7.html)\n  — real, effective, saved and filesystem user IDs, and what each one decides.\n- [systemd.exec(5)](https://man7.org/linux/man-pages/man5/systemd.exec.5.html)\n  — `User=`, `DynamicUser=`, `NoNewPrivileges=` and the capability settings.\n- [NIST SP 800-53 Rev. 5](https://csrc.nist.gov/pubs/sp/800/53/r5/upd1/final)\n  — control AC-6, least privilege, and the enhancements that make it routine.\n\n\u003chttps://engineer.company/glossary/privilege/\u003e\n","date_modified":"2026-10-20T21:59:50Z","description":"What a privilege means to the Linux kernel, a database and an organisation, how least privilege is applied to services, and how granted rights quietly pile up.","formats":{"gemtext":"https://engineer.company/glossary/privilege/index.gmi","gopher":"https://engineer.company/glossary/privilege/gophermap","html":"https://engineer.company/glossary/privilege/","json":"https://engineer.company/glossary/privilege/index.json","markdown":"https://engineer.company/glossary/privilege/index.md","pdf":"https://engineer.company/glossary/privilege/index.pdf"},"kind":"page","language":"en","title":"What is a privilege?","url":"https://engineer.company/glossary/privilege/","version":1}