Example
Worked application ยท access check
A support route missing its role check
A delivery company’s support workspace keeps private staff notes on each case. A maintenance shortcut lets any signed-in customer reach the staff review helper and read those notes, and the access check catches it.
Five routes over one case record
| Route | User | Access path |
|---|---|---|
/cases/view | Customer | Read a row, use it only after owns_case |
/cases/reply | Customer | Read a row, then use and write it after owns_case |
/staff/review | Support | Role-protected private review |
/staff/resolve | Support | Role-protected read and write |
/staff/quick-review | Support | The route repaired below |
The flawed route
route("/staff/quick-review", handler("review_case", review_case),
[ReadPerm("support_cases")]),
The check and its recorded result
api_access_check({
"sources": [{
"fileName": "support-access-before.bosatsu",
"source": COMPLETE_LINKED_SOURCE
}]
})
Tool report โ recorded: support_cases is violated.
{
"binding": "load_for_staff",
"resource": "support_cases",
"operation": "use",
"kind": "RowEscapesGuard",
"status": "violated",
"detail": "a value derived from a row of \"support_cases\" is returned outside any branch on owns_case applied to Principal.user_id and the row"
}
Repair the route, preserve the policy
- route("/staff/quick-review", handler("review_case", review_case),
+ role_route("/staff/quick-review", handler("review_case", review_case), ["support"],
[ReadPerm("support_cases")]),
The same check on the repaired source marks support_cases holds.
Run, edit, repair, and reset
Code & run Customer support access before and after
Ask your agent about anything here; it has the detail.
Where this fits
What this is about: Safety and Permissions