field-and-row-permission-ui-api-pitfalls
A defensive block for the gap between "the button is hidden" and "the server refuses". Premise: the interface
only expresses a permission; the server enforces it on every path that reads or writes the data, and the same
rule has to come out of one definition, not two. Role versus permission naming in Laravel is
skills/laravel-permissions-not-roles; scoping a query instead of checking after fetch is
skills/laravel-scope-dont-check-after-fetch; tenant isolation is skills/laravel-tenant-context-by-default;
database row-level security for generated APIs is skills/postgres-operations-and-exposed-api-pitfalls; client
trust in backend-as-a-service rules is skills/firebase-rules-and-client-trust-pitfalls; authentication and
sessions are skills/auth-session-conventions. Export mechanics are skills/csv-xlsx-import-export-pitfalls; data
tables, filters and dashboards belong to their own blocks and are not repeated here.
When
- A screen shows or edits a record where different people may see different rows or fields.
- A report says "someone saw or changed what they should not have", or a security review asks how restrictions are
enforced.
- A new endpoint, list, search, export, notification or background job reads data that has restrictions.
- A permission model is added to an application that had only authentication.
Steps
Read only the section the task meets. §2 is the entry point for any leak report.
| § |
Covers |
Read it when |
File |
| 1 |
Modelling: rule definition in one place, hide versus disable versus mask, how the interface learns what is allowed |
permissions are designed or surfaced in the UI |
01-model-and-interface.md |
| 2 |
Enforcement in the API: reads, writes, mass assignment, lists, counts, search, exports, jobs, errors, caching |
an endpoint or query touches restricted data |
02-api-enforcement-and-leaks.md |
| 3 |
Audit and verification: logging reads and changes, permission matrix tests, bulk actions, review checklist |
a rule is shipped, reviewed or investigated |
03-audit-and-verification.md |
Output / checkpoint
No pipeline checkpoint. A reviewed feature owes: the rules written once per resource, with row scope and field
lists (§1), a table of every path that reads or writes the resource and how each applies the rule (§2), a
permission-matrix test over roles, records and fields (§3), and the audit events emitted (§3).
Guardrails
- Decide access on the server for every request, whatever the interface hides. Never rely on a hidden control, a
disabled input or a client-held flag (§1, §2).
- Define each rule once and derive the interface flags from the same definition. Never keep a second copy of
the rule in the front end (§1).
- Filter rows in the query and columns in the serializer, on the write side as on the read side. Never fetch
everything and trim in the client or after the fact (§2).
- Allow-list the writable fields per role. Never pass a request body straight to a model (§2).
- Apply the same scope to lists, counts, search, exports, notifications and jobs. Never secure the detail view
alone (§2).
- Answer a refused request without confirming that a hidden record exists. Never let error text or timing reveal
what the person may not see (§2).
- Record reads of sensitive fields and every permission-relevant change. Never rely on application logs that
rotate away (§3).
- Status-code points (§2.3.1) are checked against RFC 9110; the rest is craft knowledge. Unverified points are in
references/origin.md. No application was tested.
Origin
Written from general practice in access control for business applications; the 401, 403 and 404 semantics were checked against RFC 9110, the shared-cache rules against RFC 9111, error-body leakage against RFC 9457, merge-patch nulls against RFC 7396, and the disabled-control facts against the HTML Standard and the ARIA Authoring Practices (facts only, credited). No other source was read, and no text was copied.
🟡: never run by us. Details in references/origin.md.
1---2name: field-and-row-permission-ui-api-pitfalls3description: "Use when a business application restricts what a person can see or change per record (row-level) or per attribute (field-level), or such rules are reviewed: deciding hide versus disable versus mask in the interface, enforcing the same rule in the API and the query layer (never in the client alone), mass assignment and write-side field filtering, lists, search, counts and exports that leak restricted rows or columns, permission-aware errors, caching and tenant scoping, and an audit trail of reads and changes. Framework-independent."4metadata:5 source: https://skillmd.com/skills/techmefr/field-and-row-permission-ui-api-pitfalls6---78# field-and-row-permission-ui-api-pitfalls910A defensive block for the gap between "the button is hidden" and "the server refuses". Premise: **the interface11only expresses a permission; the server enforces it on every path that reads or writes the data, and the same12rule has to come out of one definition, not two**. Role versus permission naming in Laravel is13`skills/laravel-permissions-not-roles`; scoping a query instead of checking after fetch is14`skills/laravel-scope-dont-check-after-fetch`; tenant isolation is `skills/laravel-tenant-context-by-default`;15database row-level security for generated APIs is `skills/postgres-operations-and-exposed-api-pitfalls`; client16trust in backend-as-a-service rules is `skills/firebase-rules-and-client-trust-pitfalls`; authentication and17sessions are `skills/auth-session-conventions`. Export mechanics are `skills/csv-xlsx-import-export-pitfalls`; data18tables, filters and dashboards belong to their own blocks and are not repeated here.1920## When21- A screen shows or edits a record where different people may see different rows or fields.22- A report says "someone saw or changed what they should not have", or a security review asks how restrictions are23 enforced.24- A new endpoint, list, search, export, notification or background job reads data that has restrictions.25- A permission model is added to an application that had only authentication.2627## Steps2829**Read only the section the task meets.** §2 is the entry point for any leak report.3031| § | Covers | Read it when | File |32|---|---|---|---|33| 1 | Modelling: rule definition in one place, hide versus disable versus mask, how the interface learns what is allowed | permissions are designed or surfaced in the UI | [`01-model-and-interface.md`](./references/01-model-and-interface.md) |34| 2 | Enforcement in the API: reads, writes, mass assignment, lists, counts, search, exports, jobs, errors, caching | an endpoint or query touches restricted data | [`02-api-enforcement-and-leaks.md`](./references/02-api-enforcement-and-leaks.md) |35| 3 | Audit and verification: logging reads and changes, permission matrix tests, bulk actions, review checklist | a rule is shipped, reviewed or investigated | [`03-audit-and-verification.md`](./references/03-audit-and-verification.md) |3637## Output / checkpoint38No pipeline checkpoint. A reviewed feature owes: the rules written once per resource, with row scope and field39lists (§1), a table of every path that reads or writes the resource and how each applies the rule (§2), a40permission-matrix test over roles, records and fields (§3), and the audit events emitted (§3).4142## Guardrails43- Decide access on the server for every request, whatever the interface hides. Never rely on a hidden control, a44 disabled input or a client-held flag (§1, §2).45- Define each rule once and derive the interface flags from the same definition. Never keep a second copy of46 the rule in the front end (§1).47- Filter rows in the query and columns in the serializer, on the write side as on the read side. Never fetch48 everything and trim in the client or after the fact (§2).49- Allow-list the writable fields per role. Never pass a request body straight to a model (§2).50- Apply the same scope to lists, counts, search, exports, notifications and jobs. Never secure the detail view51 alone (§2).52- Answer a refused request without confirming that a hidden record exists. Never let error text or timing reveal53 what the person may not see (§2).54- Record reads of sensitive fields and every permission-relevant change. Never rely on application logs that55 rotate away (§3).56- Status-code points (§2.3.1) are checked against RFC 9110; the rest is craft knowledge. Unverified points are in57 [`references/origin.md`](./references/origin.md). No application was tested.5859## Origin60Written from general practice in access control for business applications; the 401, 403 and 404 semantics were checked against RFC 9110, the shared-cache rules against RFC 9111, error-body leakage against RFC 9457, merge-patch nulls against RFC 7396, and the disabled-control facts against the HTML Standard and the ARIA Authoring Practices (facts only, credited). No other source was read, and no text was copied.61🟡: never run by us. Details in [`references/origin.md`](./references/origin.md).