Part 3 of 5 · 1 min read
Least privilege
Granting only what a role actually needs, and nothing more.
Think of giving a delivery driver a key that opens only the loading dock. A master key that also opens the accounting office, the server room, and every other door would be the wrong choice.
In plain words: the principle of least privilege means granting a role only the specific permissions it actually needs to do its job, nothing broader. A reporting role needs SELECT on a few tables, not INSERT, UPDATE, DELETE or access to every table in the database.
A worked example. reporting_role gets SELECT only on orders and books, never on customers.address or any write permission anywhere.
The key lines.
GRANT SELECT ON orders, books TO reporting_role;
-- deliberately not: GRANT ALL ON *.* TO reporting_role;
Principle of least privilege
The principle of least privilege is granting a role or user only the specific permissions needed for its actual job, and nothing broader than that.
Example: a role used only for monthly reports should never also hold DELETE permission on any table, since reporting never needs to delete anything.
For the curious Why over-granting is a real, common mistake
Granting broad permissions once, to avoid repeatedly handling small permission requests later, feels convenient at the time. It also means a single compromised reporting account can do far more damage than it should ever have been able to, since nothing technical stopped it from doing so.