Security model
What Rolebook guarantees, and where it stops
For security reviewers: the boundary between your app and Rolebook, the guarantees every decision keeps, the limits, where a check can go stale, what a remote or offline check trusts, and how adapters are tested.
01 · Security model
The trust boundary
- What it does
- Rolebook decides from the facts your app supplies: who is asking, their roles, the item and the context.
- Why it matters
- A decision is only as good as its inputs. Knowing the boundary tells you exactly what your app must get right.
- How it works
- Your app establishes identity, tenancy and each item's real chain through its own trusted queries. A decision says only that the rules matched those facts; it does not prove them.
Your app supplies
- Who is asking
- Their scoped roles
- The item and its chain
- Request context
Rolebook returns
- Allowed or denied
- A stable code
- A reason
- The rule that decided
02 · Security model
Guarantees in every decision
- What it does
- A fixed set of rules holds for every answer Rolebook returns.
- Why it matters
- You can reason about access without reading the engine.
- How it works
- They are enforced by the engine itself and covered by its tests.
- A person never carries roles. Access comes only from explicit, scoped assignments.
- The whole set of assignments is validated first. One malformed entry denies the request.
- Blocks are checked before allows, across every role and team.
- An unknown condition never grants an allow and still lets a block apply.
- Malformed facts never grant access, and a missing fact matches only a rule that tests for its absence.
- A field-level allow never authorizes the whole item.
- An item's chain must follow the order your policy declares. A correctly typed parent ID is still not proof that it is the real parent.
- Every decision carries a stable code and a reason.
- Rules are validated, frozen and cannot change after they load.
- check() never throws. A fault becomes a denial, and an optional reporter tells you about it.
03 · Security model
Hard limits
- What it does
- Every input has a fixed upper bound.
- Why it matters
- Evaluation always finishes in bounded time and memory, whatever a caller sends.
- How it works
- Inputs beyond a limit are denied safely. Invalid rules fail when they load, not during a request.
| Input | Limit |
|---|---|
| Roles and resource types in one policy | 128 |
| Assignments in one request | 256 |
| Teams and other groups in one request | 64 |
| Levels in an item's chain | 16 |
| Rules in one explanation trace | 64 |
| Custom roles per customer | 32 |
| Items on one page of a named query | 100 |
| Checks in one decision-service batch | 100 |
| Inspections running at once, per instance | 32 |
04 · Security model
When a check can go stale
- What it does
- A yes describes the facts at the moment of the check. If someone loses access before your write commits, a write made on that yes can still land.
- Why it matters
- Knowing where a decision can go stale tells you which writes need more than a check in front of them.
- How it works
- Read every membership or role fact a write depends on again inside the write's own transaction. Sharing changes already do this in the PostgreSQL and SQLite adapters, and protected writes do it for your own updates: the decision, your change, a receipt and an outbox event commit together or not at all. Any other write stays your app's responsibility. An answer from the decision service or from an offline bundle is a point-in-time answer too, and fences no later write.
05 · Security model
A failure to decide is never an allow
- What it does
- The decision service and offline verifier separate real decisions (allowed, explicit deny, not granted) from operational failures like timeouts, missing facts, bad signatures, or unusable clocks.
- Why it matters
- Treating an outage as an allow opens a security hole; hiding it as a normal denial masks broken infrastructure. Separating no-decision makes callers refuse the action and alert on the real cause.
- How it works
- The decision service returns HTTP 200 for real decisions and dedicated error statuses for no-decisions, never leaking internal rules or facts. The offline verifier returns a closed set of failure reasons and never falls back to older answers.
06 · Security model
What remote and offline checks trust
- What it does
- Both rely on fact sources you operate: an authority provider for the decision service, and a signing issuer for offline bundles.
- Why it matters
- Rolebook verifies signatures, freshness, caller grants, and payload shape, but cannot detect a deny assignment that your own provider omitted.
- How it works
- Test every provider against its real data source for tenant isolation, complete roles and blocks, full parent chains, and explicit error handling. For offline enforcement, qualify the device clock, anti-rollback storage, and short-lived signing keys.
07 · Security model
Inspection is opt-in, limited and recorded
- What it does
- Explaining someone else's access shows how your rules and their roles fit together, so Rolebook treats it as a privileged feature.
- Why it matters
- A support tool should not become a way to map who can see what.
- How it works
- It is off by default. When it is on, the asker needs the item's inspect permission, your limiter caps attempts, and every answer waits until your audit log has recorded it. An asker without that permission learns nothing, not even whether the item exists. An explanation is never used as a permission.
08 · Security model
The adapter security contract
- What it does
- @rolebook/sharing-testkit is a reusable set of security tests that any storage adapter must pass.
- Why it matters
- A custom adapter, or one of ours, is held to the same guarantees, checked by running the same test suite.
- How it works
- It runs with Bun, Vitest, Jest or any other runner, and covers tenant isolation, invitations, revocation, expiry, ownership, concurrent changes, listings that match single checks, and checks that fail closed.
09 · Security model
What Rolebook does not do
- What it does
- Rolebook does not sign people in, store your application items, or traverse arbitrary relationship graphs, and nothing in it opens a listening port on its own.
- Why it matters
- A small, clear job is easier to review and harder to get wrong.
- How it works
- Your app and sign-in provider own identity and application data. The HTTP API and decision service are handlers you mount inside your own server behind your own auth. Core uses flat group principals and one parent chain per item; Sharing and Teams offer opt-in bounded folder inheritance and nested team lineage on PostgreSQL and SQLite. If your access model relies on open-ended relationship graphs across services, use a relationship-based authorization database instead.
10 · Security model
Report a vulnerability
- What it does
- A suspected vulnerability goes through a private report, never a public issue, discussion or pull request.
- Why it matters
- A report that stays private protects every product built on Rolebook until a fix is out.
- How it works
- Send the affected version or commit, a minimal reproduction, the answer you saw and the one you expected, and the impact. We acknowledge the report, assess it and coordinate a fix through the same private channel. We do not promise a fixed response window, and no version is presented as externally audited.
Send your report through the contact page and say it is a security report. It reaches a person, not a public tracker. Go to the contact page