Skip to main content

Security

This document is the threat model and security contract for archenstack-rbac. It applies to every implementation of the spec — the Python, Node, Go, Rust, and Java cores, the Django adapter, the TypeScript library, and any future language. Section references (§n) point at specification, which remains normative — where this prose and the spec disagree, the spec governs.

  • Spec version: 0.6.0
  • Wire version: 1
  • Status: PRIVATE / pre-release. No license is shipped yet; all rights are reserved (license TBD). Treat this as an internal contract, not a public security commitment.

1. What Archenstack is (and is not) responsible for​

Archenstack is a pure decision core plus adapters. It answers one question: given a matrix snapshot, a role, and a feature (optionally a scope), what is the effective AccessLevel? It is not an authentication system, a session manager, a secrets store, or a network boundary.

Security-relevant responsibilities split as follows:

ConcernOwner
Deciding a role's effective level for a feature (resolve / decide)Core — deterministic, total, fail-closed
Validating a snapshot (validate) and rejecting malformed policyCore
Preventing an un-administerable matrix (check_no_lockout)Core
Canonical JSON determinism (§13)Core
Authenticating the caller and assigning them a roleHost app / adapter
Evaluating scope atom predicates (own_record, own_department, …)Host app / adapter
Object/list read filtering (querysets)Host app / adapter
Isolating your own tables' rows by tenant (a caller sees only their org's data)Host app / adapter
Transport security (TLS), storage-at-rest, secret managementDeployment

The core deliberately holds no user identities, no sessions, and no request context — those live entirely in the adapter and host app.

The tenant-data-isolation row is the one most often missed. Archenstack isolates its own tables per org — one tenant can never read another's matrix, roles, or assignments. It does not filter your domain tables: if a single instance holds a Ministry org and a County org, nothing in Archenstack stops a Ministry caller's query on your cases/documents/… tables from returning County rows, because Archenstack never sees those tables. Stamp each row with its owning org and filter every read by the caller's org, with a database-level backstop (Postgres RLS) so a forgotten WHERE cannot leak across tenants. This is cross-tenant data isolation — distinct from the intra-tenant scope atoms (own_record, own_department, own_subtree), which narrow rows within one org and which Archenstack does help you evaluate (§8).

2. Threat model​

2.1 Lock-out and the escape hatch (§12)​

Threat: an org admin edits the matrix into a state where no one can administer it any more — every rbac.manage-FULL role is lowered, deactivated, or aliased away — and the policy becomes permanently frozen.

Mitigation: check_no_lockout is evaluated before committing any mutation that could change the set of management-feature holders (override edits, role deactivation, alias edits, group deletes). The invariant requires that at least one active, non-super role still resolves to FULL on rbac.manage after the change; a violating mutation is rejected with ErrorCode.lockout and the whole change is rolled back. resolve is used inside the check, so it honors overrides and defaults exactly as a live decision would.

Escape hatch: super roles always resolve to FULL on every feature and are non-deactivatable / non-deletable (ErrorCode.immutable_field), so a superuser can always recover a matrix that has otherwise been edited into a corner. The invariant deliberately counts only non-super roles, so the ordinary (non-superuser) administration path can never be silently severed — the super role is the recovery path, not the day-to-day guarantee.

Standing assumption (the deployment's responsibility): the deployment has at least one active user actually holding a super role. check_no_lockout guarantees a non-super management-FULL holder exists inside the snapshot; the super escape hatch is only useful if a human actually holds it. The core cannot verify this — user-to-role assignment lives outside the snapshot — so deployments MUST ensure it out of band. Losing the last super user while the management-FULL holders are also removed is the one way to reach an unrecoverable state, and it is outside what the core can enforce.

2.2 Fail-closed scope evaluation (§8)​

Threat: a malformed, unknown, or adversarial ScopeExpr node is interpreted as grant rather than deny, widening access.

Mitigation: eval_scope is a pure tree-walk that fails closed. An unknown atom, a malformed node, or an unrecognized constant evaluates to false (no access), never true. The edge identities are fixed and part of the wire contract: an empty any_of is false, an empty all_of is true (vacuous truth), and any structurally invalid node is false. There is no not operator in v1, so no double-negation surface exists. Because these identities are semantic, changing any of them is a breaking wire change (§2, and see versioning).

2.3 The "caller must have a role" contract​

Threat: an authenticated caller who resolves to no role is represented as an empty/underspecified subject and slips through a check that assumed a role was present.

Mitigation: the me and policy payloads pin role to a non-empty slug (me.schema.json / policy.schema.json). A caller who resolves to no role therefore cannot be represented as a valid body — the adapter returns the standard kind:"error" envelope (not_found) instead of an invalid or default-granting response. The host app is responsible for assigning every authenticated user exactly one role. A role-less user is a host-app misconfiguration, and the contract surfaces it as an error rather than silently resolving to fallback grants.

2.4 Canonical-JSON determinism (§13)​

Threat: two conformant implementations serialize the same logical snapshot to different bytes, so signatures, content hashes, cache keys, ETags, or byte-for-byte diffs disagree across languages — an integrity and cache-overwriting surface.

Mitigation: canonical JSON is fully specified and deterministic: UTF-8, object keys sorted by UTF-16 code unit, compact separators, integer levels, lowercase \u00XX escapes for C0 controls only (U+0000–U+001F), every code point >= U+0020 (including U+007F DEL) emitted raw, and producer-deterministic array ordering. The wire-golden/ corpus pins exact bytes that every serializer MUST reproduce. This makes a snapshot's canonical bytes a stable identity that callers MAY sign or hash. The algorithm itself is part of the wire contract, so any change to it is breaking.

2.5 App-supplied atom predicates are the adapter's responsibility (§8.4)​

Threat: a scope atom like own_department is wired to the wrong object attribute (say, the object's creator instead of the caller's department), so a PARTIAL grant that should be narrow silently authorizes writes across the whole dataset.

Mitigation — and its limit: the core defines the grammar and evaluation of scope (how atoms compose, how they fail closed), but the predicate that decides whether a concrete object is "own department" / "own record" / "own team" is app-supplied by the adapter — it is never on the wire and never in the core. The core cannot verify that these predicates are correct; a mis-wired predicate is a genuine privilege bug that the core will faithfully evaluate. Predicate correctness is the adapter/host-app's responsibility and MUST be covered by the adapter's own tests. The Django adapter's ScopeEvaluator (the own_record / own_department pack) is configured through settings (owner FK fields, the department relation) so the wiring is explicit and reviewable, but the core makes no guarantee about it.

2.6 The check endpoint's object is caller-supplied (§8.6, §15.1)​

Threat: a host treats POST /permissions/check/ as authorization. Because that endpoint takes its object from the request body, the caller chooses the attributes the scope predicate reads and can describe an object it does not own:

POST /permissions/check/ { "feature": "records.edit",
"object": { "owner": "<the caller's own subject>" } }
→ { "kind": "policy", "allowed": true }

The response is not wrong — the described object would be writable — but it says nothing about the row the caller is actually trying to modify. A service layer that conditions a mutation on this answer authorizes the attacker's description of reality.

Mitigation: the endpoint is advisory, for deciding what a client renders, and §8.6 makes that normative: an implementation MUST NOT present it as an enforcement mechanism, and a host MUST NOT authorize a mutation or a data load on the strength of a check response.

Enforcement MUST re-evaluate the same scope against an object the server loaded. §8.6 therefore REQUIRES any adapter that exposes the check endpoint to also expose a scope authorizer — (caller, feature, host_loaded_object) → allow/deny — resolving through the same resolve and the same eval_scope with the same registered atoms. The only difference between the two paths is where the object came from, and that difference is the entire security boundary.

Why this is called out separately from §2.5: that threat is a mis-wired predicate — the adapter's own bug. This one is a correctly wired predicate fed an attacker-chosen object, so every component behaves exactly as specified and the result is still an authorization bypass. No amount of predicate-correctness testing detects it; only using the authorizer instead of the endpoint does.

2.7 A membership-derived bound cannot bound provisioning (§15.3)​

Threat: a deployment bounds a platform admin using a claim that means "is an administrator of these organizations" — a flag on the identity provider's membership table. Two failures follow, in opposite directions:

  • The bound is absent where it matters. A tenant being provisioned has no members, so no membership-derived claim can name it. Checking the new slug can only pass for an unbounded caller, so in practice provisioning is left unbounded — the single operation platform authority exists for is the one the bound never covers. A self-service provisioner makes this unavoidable: it derives slugs nobody can enumerate in advance.
  • Bounding one costs privilege elsewhere. To bound a parent company's governor to its subsidiaries, they must be marked an administrator inside each one, which also grants them authority within tenants they are meant to govern only from outside — and still cannot cover a subsidiary opened next quarter.

Mitigation: treat governance as its own relation. The bound MUST come from a claim naming organizations whose lifecycle the subject governs, held from outside them and NOT derived from membership. The adapter expands each named org over its own tenant tree (§15.3), so a grant covers descendants that do not exist yet, and a create is authorized against the target's parent.

Governance flows downward only: a grant over a child confers nothing over its parent or siblings. An unknown org is out-of-bound unless named outright, so a bounded principal cannot mint root tenants. An empty bound remains no authority.

Why this is separate from §2.1's lock-out concerns: nothing here is exploitable by an unprivileged caller. The damage is that a bound which looks enforced is silently inert on creation, so a deployment believes it has constrained a platform admin it has not.

2.8 Wire-version confusion (§2)​

Threat: a client resolves a snapshot under semantics that differ from the server's, silently reaching a different access decision.

Mitigation: every payload carries an integer wire_version, and an implementation MUST reject a payload whose wire_version it does not support rather than best-effort parse it. Because resolution semantics are pinned to the wire major version, an old client is fail-stopped rather than allowed to guess. See versioning.

2.9 Token transport & persistence (SPA vs SSR)​

Threat: an authentication token exfiltrated by XSS, leaked into server-rendered HTML, or replayed via CSRF grants the attacker the caller's management access.

Mitigation — the library stays transport-agnostic; the consumer picks a secure pattern:

ConsumerRecommended transportNotes
SPA (archenstack-rbac-web client)Authorization: Bearer with the token held in memory (or a token getter) — never localStorage/sessionStorage.An XSS on the admin page can ride the authenticated client regardless of storage, so in-memory / short-lived tokens limit reuse and the scope of a compromise, not the initial compromise — not a substitute for CSP / XSS defense on the admin UI.
SSR / same-site appAn httpOnly + SameSite cookie session; the client sends credentials: "include" plus a CSRF token (csrf: { header, token }) on unsafe methods.httpOnly keeps the token out of JS reach; never serialize a token into returned HTML. Cross-origin cookie mode needs an explicit Access-Control-Allow-Origin (never *) and Access-Control-Allow-Credentials: true.

Never pass a token through a DOM attribute (it lands in the serialized page) or a URL. The archenstack-rbac-web client supports both modes and prescribes neither — choosing one, and defending the admin surface against XSS, is the consumer's job.

Demo vs production: the demos use bearer-token-as-role over permissive (*) CORS and an in-page token purely for zero-setup local exploration. That configuration is INSECURE by design and must never be shipped: a real deployment provides an authentication-backed role resolver (the Java starter is fail-closed without one, §2.3) and one of the transports above.

3. Non-goals (v1)​

  • Read-object filtering is out of core. The core authorizes reads at the feature level only (level >= VIEW); which rows a caller may see is an adapter queryset concern (§9). Do not assume the core hides individual records.
  • No user/identity model. The core has no notion of users, sessions, or authentication; it resolves roles, and mapping a request to a role is the host app's job.
  • No transport or storage security. TLS, encryption at rest, and secret handling are deployment concerns.

4. Responsible disclosure​

Placeholder — this project is PRIVATE and pre-release. There is no public disclosure program yet.

If you discover a security issue in Archenstack while it remains private, report it privately to the maintainer rather than opening a public issue or pull request:

  • Contact: TBD — the maintainer's private security contact will be listed here before any public release.
  • Please include: the affected component (core / Django adapter / TS library / spec), a minimal reproduction, and the impact you observed.
  • Please do not: open a public issue, post details in a shared channel, or disclose the issue outside the project team until a fix is available.

A formal disclosure policy, response-time targets, and a security contact address will be added to this section as part of the public-release checklist.