ObjectStackObjectStack

Field-level security — hide and mask fields

Control visibility and editability of specific fields — readable/editable rules, hidden vs. read-only semantics, and server-side enforcement of declared rules.

Control visibility and editability of specific fields.

The three axes

A permission set answers three separate questions, and each key answers one of them:

AxisKeysWhat it decides
Object permissionallowRead, allowCreate, allowEdit, allowDeleteWhether the caller can use the object at all.
Record scopeviewAllRecords, modifyAllRecordsWhich records the caller reaches.
Fieldsfields rows, viewAllFields, and a field's own requiredPermissionsWhich fields of those records the caller reads and edits.

View All and Modify All do not open fields (v19). A set that holds viewAllRecords or modifyAllRecords on an object reaches every record of it and casts no field vote: a field another set hides stays hidden, and the set's own fields rows still hide or lock their fields. Where a set should read every field, grant viewAllFields. Up to v18 the two bits also read (and Modify All also edited) every field; os migrate meta --from 18 adds viewAllFields: true beside them in source.

Choosing by sensitivity

Fields are visible by default: a field that no permission set names follows the object grant. Write a rule only for an exception, and pick the mechanism by how sensitive the field is:

The field isWriteWhy
OrdinaryNothing.It follows the object grant.
Position-dependent: one position reads or edits it, another does notfields rows in the permission sets that differ.Rows union across a user's sets, and the most permissive answer wins.
High-sensitivity: salary, ID numbersrequiredPermissions on the field itself, plus maskingRule where a partial value is needed.The capability gate is applied after the sets are merged, so no field row, viewAllFields, View All or Modify All re-opens the field.
// On the object: the gate travels with the field.
fields: {
  salary:    { type: 'currency', requiredPermissions: ['hr.view_compensation'] },
  id_number: { type: 'text', requiredPermissions: ['hr.view_identity'], maskingRule: 'id_card' },
}

// On the permission set whose holders read both in full.
definePermissionSet({
  name: 'hr_specialist',
  systemPermissions: ['hr.view_compensation', 'hr.view_identity'],
  objects: { employee: { allowRead: true, allowEdit: true } },
});

A caller who does not hold the capability gets salary stripped from every record and reads id_number as its masked value. A write to either field is refused.

viewAllFields: a set that reads every field

viewAllFields: true on a set's object entry casts a read vote on every field of that object, fields added later included. Use it for admin-like sets that must read everything:

definePermissionSet({
  name: 'sales_manager',
  objects: { crm_account: { allowRead: true, allowEdit: true, viewAllFields: true } },
  // The set's own row beats its own bit: its holders do not read this field.
  fields: { 'crm_account.partner_margin': { readable: false } },
});
  • Read only. It never casts an edit vote. An edit comes from the default (a field no set names follows the object grant) or from an explicit editable: true row.
  • A set's own row beats it. A readable: false row in the same set keeps that field hidden for that set. Another set's viewAllFields still reads the field, because grants union across sets.
  • A field vote only. It grants no object access, so pair it with allowRead. It widens no record: that is viewAllRecords.
  • On the '*' entry it votes on every object the set does not name itself, private objects (access.default: 'private') included. A '*' entry without View All or Modify All gives no access to a private object, but its viewAllFields still votes on that object's fields. So it re-opens a field that is hidden by the set which does grant the object.
  • A capability gate still applies. It does not lift a field's requiredPermissions or a masking rule.
  • High-privilege. A set that carries it cannot be bound to the everyone or guest audience.
  • Authored in metadata. Studio's permission matrix has no control for the bit. It keeps the key when it saves a set that already carries it.

Field Permissions in Permission Sets

Field permissions are keyed <object>.<field> and use readable / editable, plus an optional when — a row condition on the edit vote (below):

fields: {
  // Read-only: visible but not editable
  'account.annual_revenue': { readable: true, editable: false },
  'account.description': { readable: true, editable: true },
  // Hidden: not visible at all
  'account.ssn': { readable: false, editable: false },
  'opportunity.amount': { readable: true, editable: true },
  'opportunity.probability': { readable: true, editable: false },
}

Row-conditioned edit locks (when)

An entry may carry when: a row condition in the same canonical CEL as an RLS using predicate (a field of the object compared with a literal or a current_user.* value; ==, !=, <, <=, >, >=, in, combined with && / ||). The entry then votes only on the rows the condition matches and is absent on every other row, as if the set had not declared the field:

fields: {
  // Locked from approval onward; a draft is still editable.
  'opportunity.amount': { readable: true, editable: false, when: "status in ['approved', 'closed']" },
  // Editable on the caller's own rows only.
  'task.estimate': { readable: true, editable: true, when: 'assigned_to == current_user.id' },
}
  • Edit vote only. Reads are judged row-blind, so readable: false beside a when is refused at parse time; keep readable: true (the default) on a row-conditioned entry.
  • Which row. The write gate judges the stored row before an update (a lock on status in [...] holds on an approved row even when the same write moves status back), and each incoming row of an insert, as the caller sent it. The condition is evaluated in process against the row — never rewritten into the query.
  • When no row can be judged — a predicate (bulk) update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request — the entry is applied as its lock: no edit grant on that write, and a WARN line says why.
  • Readers that hold no row (/auth/me/permissions, the object-wide writable-field projections, os explain) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. os explain names each such entry as a row-conditioned lock in its fls layer.
  • The record-scoped projection holds the row. GET /api/v1/data/{object}/{id}/field-access (client.data.fieldAccess) answers the fields the caller may read and the fields it may write on that record, and its editable list is the write gate's own verdict on an update of the stored row. So a lock that applies from a stage onward disables the field only on the rows its condition names — this is the answer a record's edit form and the record page's in-place edit read. A list view's inline edit locks a whole column, which cannot split per row, so it keeps the row-blind answer. A row that is absent or that the caller cannot read answers the record read's 404. editable is field-level only: the object grant and the record's row-level write scope (sharing, row-level security, ownership) are not part of it. Those are writable, the row's own verdict: false on a row the caller may read but not write, where an update is refused as a whole, so a client need not offer the edit at all. It comes from the write gate too, run over an update of the row without performing it. A stored row outside a row-level check also answers false: an update that leaves it as it is fails the check, while a save that moves the checked value back inside it can pass. true does not promise a save succeeds: a pending approval's record lock, rules judged on the values sent (conditional read-only, validation), a data source that refuses writes, the platform's own rules for its own records (comments, attachments, mail messages, approval requests) and an object the API serves read-only still apply when the record is saved.
  • Union without deny is unchanged. A matched conditioned lock is still out-voted by another set's unconditioned editable: true; an entry without when votes on every row, as before (ADR-0066 ⑧, note of 2026-10-26).
  • Validated at authoring. objectstack validate judges when like an RLS predicate (rls-predicate-* findings on permissions[].fields[].when): the fields it names must exist on the entry's object, no cross-object reach, no unresolvable current_user.* variable.
  • In Studio. The permission-set form offers the condition on each field row under When (edit), in the same CEL editor as the row-level security clauses, linted the same way; a condition the publish gate would refuse holds the save. Switching Read off clears the condition, and the Read-only all / Write all shortcuts keep it. A field row with no rule shows the object's own Read / Edit in grey, marked as following the object; a click or a shortcut writes a rule only for the boxes it changes, and Clear returns the visible rows to the object grant.

For an administrator's walk-through (the editor path, the matching metadata, and when a validation rule is the better tool), see the recipe Lock fields for a position once a record reaches a stage.

Hidden vs. Read-Only

// Hidden: Field not visible at all
{ readable: false, editable: false }

// Read-Only: Field visible but not editable
{ readable: true, editable: false }

// Editable: Field visible and editable
{ readable: true, editable: true }

Server-side enforcement of declared rules

The client-side ObjectForm / inline grid hides non-editable fields from the UI — but that is a UX layer only. The SecurityPlugin middleware enforces field-level write rules on the server, regardless of how the request arrived (REST, SDK, raw ObjectQL call).

On read — find / findOne results have non-readable fields stripped from every record before the response leaves the engine.

Computed fields follow their inputs — a computed field (a formula, or a stored field with an expression) is withheld from a caller who is not served whole a field it reads: a field of its own record the caller may not read (a permission set marks it readable: false, or the caller fails its requiredPermissions) or is served masked (its maskingRule), whether the expression names it directly, inside a function such as label(), or through another computed field; or a field the referenced object declares, on the record the expression reads through one reference, where the caller may not read that object, may not read the field, or is served it masked — a stored field there withheld for what it reads through a reference of its own included, however long the chain and wherever it comes back to an object it has already passed through. What is judged is the field, not the row: a computed field is not withheld because the caller may not read the particular record a reference points at (a formula reads null there; a stored one keeps the value its writer computed). A withheld computed field is stripped from records, refused as a filter, sort, group or aggregate input (a stored one; a formula is refused there for every caller), refused when a write payload names it (as is a computed field the caller is served masked), served by its floor name where it is the name of a record shown through referenceNameVisible, and left out of the fields served to that caller, including the object schema and the writable fields. A computed field whose expression reads the record in a way no field name describes (a computed key such as record[record.k], a method or macro on record, record passed whole to a function, or a dialect other than CEL) is withheld whenever some other field of the object is not served whole to that caller, and for what it reads through a reference as any other computed field is. A summary roll-up is not a computed field in this sense: it does not follow the fields it aggregates, so mask it on its own where a set must not see it. The record the engine echoes for a public-form submission carries no computed field that reads through a reference. viewAllFields lifts a permission set's readable: false, not a capability gate or a masking rule, so its holders are withheld a computed field over such a field too. To let a permission set's holders read a computed field, grant that set read on every field the expression reads, unmasked: the capability a field's requiredPermissions names also lifts a masking rule it gates, and a masking rule with no gate masks the field for every caller until the field declares one.

On write — insert / update requests are checked before the operation reaches the driver. If the payload contains any field the caller is not permitted to edit, the engine throws PermissionDeniedError (mapped to HTTP 403) with the offending field names in details.forbiddenFields:

{
  "name": "PermissionDeniedError",
  "code": "PERMISSION_DENIED",
  "statusCode": 403,
  "message": "[Security] Field write denied: not permitted to edit [salary, ssn] on 'employee'",
  "details": {
    "operation": "insert",
    "object": "employee",
    "forbiddenFields": ["salary", "ssn"]
  }
}

Why throw instead of silently stripping? Silent strip hides the security boundary from honest clients (their update "doesn't save" and they cannot tell why) AND gives a probing client no signal that the field exists. Throwing makes the boundary observable in both directions — legitimate UIs get an actionable error to fix; probing clients learn nothing they could not already infer.

Default-visible (block-list) semantics. Fields without an explicit rule pass through untouched — readable and writable. Permission sets only constrain fields they explicitly enumerate, and field grants union most-permissively across a user's sets (one set's readable: true out-votes another set's false). Until a subtractive muting layer lands (ADR-0066 ⑧), a { readable: false } rule masks the field only as long as no other set the user holds declares it readable: true or carries viewAllFields on that object (View All and Modify All cast no field vote) — so gate a high-sensitivity field with requiredPermissions (Choosing by sensitivity), grant a position-dependent field only in the sets that need it, and treat a sensitive field on a broadly-granted object as a review smell — see the FLS posture warning. Declared rules themselves are enforced fail-closed: a masked field is stripped on read and a write to a non-editable field throws.

Bulk inserts. Arrays are checked row-by-row; a single offending field in any row rejects the whole batch atomically.

System operations. ExecutionContext { isSystem: true } bypasses the check entirely — used for migrations, seed loading, and audit log writes.


See also

On this page