Caretaker Express · PostgreSQL · Cedar

Module 9 · Trust boundaries and architecture

9.1 Forged input, and what Cedar cannot know

Send forged roles, user IDs, building IDs and attributes in every place a client controls, show that Caretaker ignores them, and then show exactly what Cedar would do if the server believed them.

≈ 25 min 6 steps 61 lines of code Replay verified

Starting point

Every decision comes from Cedar, with entities built by our mapper from the session and the database. The isolation suite proves foreign identifiers are refused.

Outcome

Text
test/forged-input.test.js        (new)scripts/forged-entity-demo.js    (new)

You can list every input of a request, say whether it is trusted, and explain why Cedar cannot protect you from false entity data that has the right shape.

The problem

An attacker controls the whole HTTP request: method, path, query string, headers, cookies and body. They will try to tell the server who they are and what they may do:

  • a hidden form field role=building_admin;
  • a header X-User-Id: 3 (Carol);
  • a query string ?adminBuildings=10,20,30;
  • a JSON body or form field that names another building or another reporter.

None of this matters if the server never reads permissions from the request. Cedar itself is no defence here: it evaluates whatever entities it is given. If the mapper ever copied a request field into an entity, Cedar would compute a perfectly correct decision about false facts.

Build it

1. Where each value comes from

Input Example Trusted? How Caretaker uses it
Session cookie value caretaker.sid=s%3A... No, until verified Signature checked, then used only to find a session row
Session row { "userId": 1 } Yes Written by the server after a correct password; the only source of identity
req.user and req.user.access user row, memberships, assignments Yes Loaded from the database on every request
URL path IDs /issues/101 No Only says which row to load; the row decides everything else
Form fields and query string building_id, role, status No Validated; IDs are proposals that are looked up; never copied into entities
Headers X-User-Id No Ignored
Database rows issue, building, inspection rows Yes, as far as the database is Mapped into entities
Cedar context targetUser, role Built by the server From validated values (grant) or stored rows (revoke)
Policies and schema src/authz/* Yes Code-reviewed files in Git, validated at startup

2. Prove the app ignores forged permissions

Create filetest/forged-input.test.jsJavaScript
import { test, before, after } from 'node:test';import assert from 'node:assert/strict';import { pool } from '../src/db.js';import { resetDatabase, loginAs } from './helpers.js'; let dave;before(async () => {  await resetDatabase();  dave = await loginAs('dave');});after(() => pool.end()); test('headers that claim another identity are ignored', async () => {  const res = await dave.get('/organisations/1/edit').set('X-User-Id', '3').set('X-Role', 'org_admin');  assert.equal(res.status, 403);}); test('query strings and form fields that claim roles are ignored', async () => {  assert.equal((await dave.get('/issues/101/edit?role=building_admin&adminBuildings=10')).status, 403);  const res = await dave.post('/issues/101/delete').type('form').send({ role: 'building_admin', adminBuildings: '10', userId: '3' });  assert.equal(res.status, 403);  assert.equal((await pool.query('SELECT 1 FROM issues WHERE id = 101')).rowCount, 1);}); test('a forged reporter or status in an edit form does not reach the database', async () => {  const res = await dave.post('/issues/103/edit').type('form').send({    title: 'Front door lock sticks at entrance 4', priority: 'medium', status: 'open', occurred_at: '2026-11-08T07:05',    reported_by: '1', building_id: '30', organisation_id: '2',  });  assert.equal(res.status, 303);  const { rows } = await pool.query('SELECT reported_by, building_id FROM issues WHERE id = 103');  assert.deepEqual(rows, [{ reported_by: 4, building_id: 20 }]);}); test('a forged grant context cannot make dave a building admin', async () => {  const res = await dave.post('/buildings/20/access').type('form').send({ user_id: '4', role: 'building_admin', targetUser: '1' });  assert.equal(res.status, 403);});

The third test is the subtle one. Dave is allowed to edit issue 103 (he reported it). His form also says reported_by=1, building_id=30, organisation_id=2. If any of those reached updateIssue or the mapper, Dave could hand the issue to Alice, move it to another tenant, or change which organisation Cedar thinks it belongs to. The database row afterwards shows none of that happened.

3. What Cedar would do with a false fact

Now the counterfactual, in a standalone script. We build Alice's real request for issue 105 (Harbour Lets), then imagine a mapper bug that merged a request field into her entity:

Create filescripts/forged-entity-demo.jsJavaScript
// What Cedar decides when the entity data is false but well-formed. Standalone demonstration.import { pool } from '../src/db.js';import { findUserById } from '../src/models/users.js';import { loadAccess } from '../src/models/access.js';import { findIssue } from '../src/models/issues.js';import { buildAuthorizationCall } from '../src/authz/request.js';import { evaluate } from '../src/authz/cedar.js';import { ref } from '../src/authz/entities.js'; const alice = await findUserById(1);alice.access = await loadAccess(1);const issue = await findIssue(105); const honest = buildAuthorizationCall(alice, 'ViewIssue', issue);console.log('honest entities:', JSON.stringify(honest.entities[0].attrs.adminBuildings), '->', evaluate(honest).decision); // Imagine the mapper had done: attrs.adminBuildings.push(...req.body.adminBuildings)const forged = structuredClone(honest);forged.entities[0].attrs.adminBuildings.push(ref('Building', 30));const result = evaluate(forged);console.log('forged entities:', JSON.stringify(forged.entities[0].attrs.adminBuildings), '->', result.decision, result.reasons.join(','), result.errors.length ? result.errors : 'no errors'); await pool.end();

Run and inspect

Run and comparecaretaker/
npm test

> caretaker@1.0.0 test
> node --env-file=.env.test --test --test-concurrency=1 --test-reporter=spec "test/**/*.test.js"

✔ view issue 101 (building 10) (508.635375ms)
✔ edit issue 101 (28.093292ms)
✔ view issue 103 (building 20) (24.061375ms)
✔ edit issue 103 (reported by dave) (23.393667ms)
✔ report an issue at building 20 (26.337792ms)
✔ view issue 105 (building 30) (20.952917ms)
✔ view issue 106 (building 40, reported by bob) (17.225667ms)
✔ approve inspection 201 (created by dave) (19.876875ms)
✔ approve inspection 202 (created by alice) (23.136667ms)
✔ update organisation 1 (17.290167ms)
✔ change own role at building 10 (5.8575ms)
✔ grant building_admin at building 10 to dave (23.707ms)
✔ grant viewer at building 10 to dave (19.694958ms)
✔ issues in each user's list come only from the expected buildings (124.948166ms)
✔ the scenario loads exactly as specified (210.180625ms)
✔ only one active assignment per user, building and role (1.116667ms)
✔ a revoked role can be granted again (0.971041ms)
✔ the My access page shows what the server loaded (75.057333ms)
✔ a correct login creates a session and shows the user (307.234ms)
✔ a wrong password or unknown email gets the same 401 (74.9655ms)
✔ registration validates, creates a user, and logs them in (39.089ms)
✔ registering an existing email is a field error (27.761875ms)
✔ logout destroys the session (49.332667ms)
✔ allow: a permit matched and nothing forbade it (348.720041ms)
✔ explicit deny: a forbid overrides a matching permit (3.059458ms)
✔ implicit deny: no permit matched (2.455417ms)
authz problem {
  user: 1,
  action: 'ApproveInspection',
  resource: 'Inspection::201',
  decision: 'failure',
  errors: [
    'entity does not conform to the schema: in attribute `status` on `Caretaker::Inspection::"201"`, type mismatch: value was expected to have type string, but it actually has type long: `7`'
  ]
}
✔ failure: a row that does not fit the schema is never allowed (3.770333ms)
Show 105 more lines✔ unknown actions throw instead of deciding (6.662667ms) ✔ revoking dave's inspector role at building 10 takes effect on his next request (412.853875ms) ✔ a revoked assignment cannot be revoked again (4.967875ms) ✔ an assignment id from another building is not found here (6.02325ms) ✔ alice cannot revoke her own building_admin role; carol can (12.798584ms) ✔ grants are limited to members of the building's organisation (6.02025ms) ✔ a building can be created inside an organisation (290.346708ms) ✔ a duplicate building name in the same organisation is a field error (5.754209ms) ✔ the same building name is allowed in another organisation (10.088042ms) ✔ a building with issues cannot be deleted (14.262125ms) ✔ an empty building can be deleted (9.776833ms) ✔ an organisation with buildings cannot be deleted, an empty one can (24.873417ms) ✔ a logged-in POST without a token is refused with 403 (282.433ms) ✔ a token from another session is refused (34.363209ms) ✔ the right token in the form field works (18.543ms) ✔ every POST form on every page carries the token (55.807ms) ✔ the dashboard counts match the database (291.981291ms) ✔ only the buildings carol can see appear (6.38175ms) ✔ headers that claim another identity are ignored (289.1315ms) ✔ query strings and form fields that claim roles are ignored (12.098875ms) ✔ a forged reporter or status in an edit form does not reach the database (5.380917ms) ✔ a forged grant context cannot make dave a building admin (4.559209ms) ✔ create a draft, edit it, submit it, approve it (347.22ms) ✔ invalid transitions are refused with 409 and change nothing (11.631333ms) ✔ only drafts can be edited (5.361583ms) ✔ returning a submitted inspection makes it editable again (8.01125ms) ✔ concurrent approvals: exactly one wins (24.436916ms) ✔ unknown actions are 404 (3.426958ms) ✔ the issues list contains only issues from visible buildings (585.976958ms) ✔ a filter for another tenant's building returns nothing (3.783042ms) ✔ the inspections list is scoped too (10.173167ms) ✔ organisations are listed for their members only (8.620541ms) ✔ the dashboard counts only visible data (7.12725ms) ✔ view issue 101 (building 10) (470.353667ms) ✔ open the edit form for issue 101 (22.333334ms) ✔ open the edit form for issue 103 (reported by dave, building 20) (22.779958ms) ✔ view issue 105 (building 30) and 106 (building 40) (42.200875ms) ✔ report an issue at building 20 (28.460375ms) ✔ a reporter cannot edit their own issue once it is closed (9.06725ms) ✔ only building admins may delete; refusals change nothing (17.634958ms) ✔ the edit form cannot move an issue to another building (4.09575ms) ✔ the list pages 10 at a time and reports the total (312.026458ms) ✔ pages do not overlap (23.215666ms) ✔ filters combine with AND (7.126417ms) ✔ sorting by priority puts critical first when descending (7.259834ms) ✔ unknown sort keys and SQL in the query string are ignored (42.260125ms) ✔ alice may update 101 at building 10 but may not create at building 20, so she cannot move it there (348.150125ms) ✔ dave may update his own issue 103 but is not a reporter at building 10 (7.059875ms) ✔ dave cannot move issue 101: he may not update it where it is (5.382875ms) ✔ carol moves 101 to building 20, but never to another organisation (10.411584ms) ✔ a forged building id on create is refused and creates nothing (25.440583ms) ✔ GET /issues lists issues from the database (294.204042ms) ✔ GET /issues/101 shows one issue with its building (7.175416ms) ✔ GET /issues/:id answers 404 for unknown or malformed ids (14.215083ms) ✔ POST /issues re-renders the form with errors (5.142875ms) ✔ POST /issues stores the issue and redirects to it (8.459292ms) ✔ POST /issues with a building that does not exist is a form error, not a 500 (4.331625ms) ✔ the stored row has the cleaned values and ignores a client-sent status (3.945417ms) ✔ an issue time in the future is rejected (4.698541ms) ✔ GET /issues/101/edit shows the current values (5.736208ms) ✔ POST /issues/:id/edit changes the status and updated_at (5.748584ms) ✔ POST /issues/:id/delete removes the issue (11.223917ms) ✔ the issues list contains exactly the issues Cedar lets each user view (336.435084ms) ✔ the inspections list contains exactly the inspections Cedar lets each user view (24.382708ms) ✔ only organisation admins can open the members page (432.251375ms) ✔ controlled onboarding: carol adds nora; nora sees the organisation but no building (17.023208ms) ✔ promoting dave to org_admin gives him the organisation's admin rights on his next request (12.110417ms) ✔ nobody changes their own membership (3.867792ms) ✔ unknown emails and roles are form errors (11.040166ms) ✔ a member cannot add members, even with a well-formed request (3.694916ms) ✔ GET /organisations lists organisations with building counts (275.921458ms) ✔ GET /organisations/1 shows its buildings, not other organisations' buildings (14.47975ms) ✔ POST /organisations validates and creates (14.220666ms) ✔ POST /organisations/:id/edit renames the organisation (10.984583ms) ✔ unknown organisations are 404 (6.285292ms) ✔ every policy is valid against the schema (32.797125ms) ✔ every action used by the app is mentioned by a policy, directly or through its group (9.513833ms) ✔ failed logins are limited per client; the limit then blocks even correct passwords (355.449125ms) ✔ anonymous requests are redirected to the login page (219.638625ms) ✔ anonymous writes are refused and change nothing (11.150625ms) ✔ login and register pages stay public (5.564042ms) ✔ login issues a new session id (no session fixation) (33.057125ms) ✔ returnTo only follows local paths (27.994208ms) ✔ new issues and transitions record the logged-in user (90.64675ms) ✔ the session cookie has the attributes we chose (26.236833ms) ✔ organisation 1: view and update (493.657083ms) ✔ ravi is still a member of organisation 2 but can see none of its buildings (11.632959ms) ✔ building 10: view, update, delete (60.618375ms) ✔ creating buildings needs org_admin (19.095ms) ✔ creating an organisation makes the creator its admin (9.804166ms) ✔ inspections: view 201, open the edit form for draft 203 (44.440709ms) ✔ approve inspection 201 (dave's): only building admins (19.027667ms) ✔ creating an inspection needs inspector or building_admin at the chosen building (12.597459ms) ✔ bob gets 404 for every Liffey route, and nothing changes (477.173292ms) ✔ ravi gets 404 for every Liffey route, and nothing changes (105.110708ms) ✔ nora gets 404 for every Liffey route, and nothing changes (92.059375ms) ✔ inside one tenant: alice, a viewer at building 20, cannot change anything there (65.081708ms) ℹ tests 124 ℹ suites 0 ℹ pass 124 ℹ fail 0 ℹ cancelled 0 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 14228.585125
Run and comparecaretaker/
node --env-file=.env scripts/forged-entity-demo.js
honest entities: [{"type":"Caretaker::Building","id":"10"}] -> deny
forged entities: [{"type":"Caretaker::Building","id":"10"},{"type":"Caretaker::Building","id":"30"}] -> allow building-read no errors

With honest entities, Alice's adminBuildings is [Building::"10"] and the answer is deny. With one forged reference added, the answer is allow, reasons building-read (and building-admin would allow edits too), with no errors. The forged entity has exactly the right shape: a set of Building references. The schema accepts it, the policies evaluate it, and the decision is correct for the data given. Cedar has no way to know that Alice never held a role at building 30.

That is the precise boundary of what a policy engine does. It makes decisions consistent with the facts you supply. Whether those facts are true is the job of the code around it: authentication, the mapper, and the database.

Try the same idea interactively. The explorer below runs the real engine; each toggle lets one client-supplied value leak into the entities:

Loading interactive explorer…

Experiment

Predict Our mapper never reads req.body. Name one other way a false fact could reach Cedar without any code reading the request.
Reveal Some answers
  • Stale data. If entity data were cached and a role was revoked after caching, the cache is a false fact until it expires (lesson 9.3).
  • A compromised database or a bad migration. A wrongly inserted assignment row is a "true" fact for the mapper.
  • Another service. If a separate service supplied attributes and trusted its caller, the falsehood enters there (lesson 9.2).
  • A mapping bug. A wrong join (for example, the building of the wrong issue) produces well-formed false entities.

In each case Cedar decides correctly about wrong data. The defences are: load facts from the source of truth on each request, validate the shape with the schema, test the mapper (parity and matrix tests), and limit who can write the facts (lesson 9.3).

Checkpoint

Run and comparecaretaker/
npm test

> caretaker@1.0.0 test
> node --env-file=.env.test --test --test-concurrency=1 --test-reporter=spec "test/**/*.test.js"

✔ view issue 101 (building 10) (472.835291ms)
✔ edit issue 101 (27.195875ms)
✔ view issue 103 (building 20) (26.613791ms)
✔ edit issue 103 (reported by dave) (22.262042ms)
✔ report an issue at building 20 (24.691083ms)
✔ view issue 105 (building 30) (19.168625ms)
✔ view issue 106 (building 40, reported by bob) (21.353167ms)
✔ approve inspection 201 (created by dave) (16.4475ms)
✔ approve inspection 202 (created by alice) (17.785917ms)
✔ update organisation 1 (19.855625ms)
✔ change own role at building 10 (4.944667ms)
✔ grant building_admin at building 10 to dave (22.839041ms)
✔ grant viewer at building 10 to dave (18.365209ms)
✔ issues in each user's list come only from the expected buildings (122.707667ms)
✔ the scenario loads exactly as specified (210.605834ms)
✔ only one active assignment per user, building and role (0.851834ms)
✔ a revoked role can be granted again (1.369ms)
✔ the My access page shows what the server loaded (72.851917ms)
✔ a correct login creates a session and shows the user (275.197709ms)
✔ a wrong password or unknown email gets the same 401 (54.495791ms)
✔ registration validates, creates a user, and logs them in (46.110125ms)
✔ registering an existing email is a field error (29.077792ms)
✔ logout destroys the session (51.300375ms)
✔ allow: a permit matched and nothing forbade it (216.979333ms)
✔ explicit deny: a forbid overrides a matching permit (2.918209ms)
✔ implicit deny: no permit matched (2.42875ms)
authz problem {
  user: 1,
  action: 'ApproveInspection',
  resource: 'Inspection::201',
  decision: 'failure',
  errors: [
    'entity does not conform to the schema: in attribute `status` on `Caretaker::Inspection::"201"`, type mismatch: value was expected to have type string, but it actually has type long: `7`'
  ]
}
✔ failure: a row that does not fit the schema is never allowed (3.258167ms)
Show 105 more lines✔ unknown actions throw instead of deciding (1.511125ms) ✔ revoking dave's inspector role at building 10 takes effect on his next request (398.493917ms) ✔ a revoked assignment cannot be revoked again (4.700292ms) ✔ an assignment id from another building is not found here (4.323125ms) ✔ alice cannot revoke her own building_admin role; carol can (11.796125ms) ✔ grants are limited to members of the building's organisation (6.110458ms) ✔ a building can be created inside an organisation (292.177084ms) ✔ a duplicate building name in the same organisation is a field error (6.492375ms) ✔ the same building name is allowed in another organisation (8.988334ms) ✔ a building with issues cannot be deleted (15.571084ms) ✔ an empty building can be deleted (11.259209ms) ✔ an organisation with buildings cannot be deleted, an empty one can (27.088542ms) ✔ a logged-in POST without a token is refused with 403 (277.920083ms) ✔ a token from another session is refused (36.941041ms) ✔ the right token in the form field works (20.853417ms) ✔ every POST form on every page carries the token (57.124584ms) ✔ the dashboard counts match the database (279.541833ms) ✔ only the buildings carol can see appear (5.243458ms) ✔ headers that claim another identity are ignored (278.397833ms) ✔ query strings and form fields that claim roles are ignored (13.179125ms) ✔ a forged reporter or status in an edit form does not reach the database (5.97275ms) ✔ a forged grant context cannot make dave a building admin (5.117084ms) ✔ create a draft, edit it, submit it, approve it (336.02575ms) ✔ invalid transitions are refused with 409 and change nothing (12.307625ms) ✔ only drafts can be edited (5.307ms) ✔ returning a submitted inspection makes it editable again (7.566542ms) ✔ concurrent approvals: exactly one wins (24.423458ms) ✔ unknown actions are 404 (3.195792ms) ✔ the issues list contains only issues from visible buildings (590.753125ms) ✔ a filter for another tenant's building returns nothing (3.994416ms) ✔ the inspections list is scoped too (9.8935ms) ✔ organisations are listed for their members only (8.577792ms) ✔ the dashboard counts only visible data (6.409208ms) ✔ view issue 101 (building 10) (462.006708ms) ✔ open the edit form for issue 101 (28.298625ms) ✔ open the edit form for issue 103 (reported by dave, building 20) (24.145542ms) ✔ view issue 105 (building 30) and 106 (building 40) (40.437791ms) ✔ report an issue at building 20 (26.355792ms) ✔ a reporter cannot edit their own issue once it is closed (11.654042ms) ✔ only building admins may delete; refusals change nothing (18.211291ms) ✔ the edit form cannot move an issue to another building (4.036084ms) ✔ the list pages 10 at a time and reports the total (299.068959ms) ✔ pages do not overlap (23.132541ms) ✔ filters combine with AND (7.00125ms) ✔ sorting by priority puts critical first when descending (7.254166ms) ✔ unknown sort keys and SQL in the query string are ignored (40.601916ms) ✔ alice may update 101 at building 10 but may not create at building 20, so she cannot move it there (355.328792ms) ✔ dave may update his own issue 103 but is not a reporter at building 10 (6.725958ms) ✔ dave cannot move issue 101: he may not update it where it is (5.79575ms) ✔ carol moves 101 to building 20, but never to another organisation (13.089833ms) ✔ a forged building id on create is refused and creates nothing (26.088959ms) ✔ GET /issues lists issues from the database (286.140959ms) ✔ GET /issues/101 shows one issue with its building (7.166958ms) ✔ GET /issues/:id answers 404 for unknown or malformed ids (15.463167ms) ✔ POST /issues re-renders the form with errors (5.387083ms) ✔ POST /issues stores the issue and redirects to it (8.126958ms) ✔ POST /issues with a building that does not exist is a form error, not a 500 (4.279584ms) ✔ the stored row has the cleaned values and ignores a client-sent status (4.113292ms) ✔ an issue time in the future is rejected (3.95325ms) ✔ GET /issues/101/edit shows the current values (5.187625ms) ✔ POST /issues/:id/edit changes the status and updated_at (5.223834ms) ✔ POST /issues/:id/delete removes the issue (11.551708ms) ✔ the issues list contains exactly the issues Cedar lets each user view (331.733833ms) ✔ the inspections list contains exactly the inspections Cedar lets each user view (20.435459ms) ✔ only organisation admins can open the members page (448.405833ms) ✔ controlled onboarding: carol adds nora; nora sees the organisation but no building (15.179292ms) ✔ promoting dave to org_admin gives him the organisation's admin rights on his next request (15.487375ms) ✔ nobody changes their own membership (4.244375ms) ✔ unknown emails and roles are form errors (10.305458ms) ✔ a member cannot add members, even with a well-formed request (6.074458ms) ✔ GET /organisations lists organisations with building counts (254.640958ms) ✔ GET /organisations/1 shows its buildings, not other organisations' buildings (14.386459ms) ✔ POST /organisations validates and creates (15.695792ms) ✔ POST /organisations/:id/edit renames the organisation (11.513125ms) ✔ unknown organisations are 404 (6.329459ms) ✔ every policy is valid against the schema (32.444541ms) ✔ every action used by the app is mentioned by a policy, directly or through its group (9.361583ms) ✔ failed logins are limited per client; the limit then blocks even correct passwords (345.082791ms) ✔ anonymous requests are redirected to the login page (218.905459ms) ✔ anonymous writes are refused and change nothing (11.268125ms) ✔ login and register pages stay public (5.963209ms) ✔ login issues a new session id (no session fixation) (32.760208ms) ✔ returnTo only follows local paths (30.789ms) ✔ new issues and transitions record the logged-in user (100.909292ms) ✔ the session cookie has the attributes we chose (27.429333ms) ✔ organisation 1: view and update (505.81475ms) ✔ ravi is still a member of organisation 2 but can see none of its buildings (8.1515ms) ✔ building 10: view, update, delete (58.163ms) ✔ creating buildings needs org_admin (17.484333ms) ✔ creating an organisation makes the creator its admin (9.26275ms) ✔ inspections: view 201, open the edit form for draft 203 (43.457625ms) ✔ approve inspection 201 (dave's): only building admins (19.127125ms) ✔ creating an inspection needs inspector or building_admin at the chosen building (13.825667ms) ✔ bob gets 404 for every Liffey route, and nothing changes (451.039125ms) ✔ ravi gets 404 for every Liffey route, and nothing changes (96.683209ms) ✔ nora gets 404 for every Liffey route, and nothing changes (97.252958ms) ✔ inside one tenant: alice, a viewer at building 20, cannot change anything there (63.18725ms) ℹ tests 124 ℹ suites 0 ℹ pass 124 ℹ fail 0 ℹ cancelled 0 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 13897.383916
Run and comparecaretaker/
git add -A
git commit -m "Forged input tests and the forged-entity demonstration"
[main 4f3c87f] Forged input tests and the forged-entity demonstration
 2 files changed, 61 insertions(+)
 create mode 100644 scripts/forged-entity-demo.js
 create mode 100644 test/forged-input.test.js
Symptom The forged-input edit test shows building_id: 30

Some code path passes req.body (or values) to updateIssue without overriding building_id. The edit route must call updateIssue(issue.id, { ...record, building_id: issue.building_id }).

Recap and next step

The client controls the request, so nothing in it is a statement of identity or permission; IDs are only proposals to look up, and the context is built by the server. Tests prove forged headers, query strings and form fields change nothing. And a well-formed false entity makes Cedar allow, without errors, which is why the code that builds entities is security-critical.

Next we name the parts of our authorization architecture with the standard terms, and build an optional separate decision service to see what moves and what must not.