POST /api/v2/envelope/field/update-many accepts a field that is both required and read-only
Issue Description
#3290 fixed the create path; the update path has the same hole. updateEnvelopeFields (packages/lib/server-only/field/update-envelope-fields.ts) validates recipients, item ownership, and the field-meta/type match, but never inspects the fieldMeta it persists — and the update replaces the meta wholesale (fieldMeta: updateData.fieldMeta), so:
POST /api/v2/envelope/field/update-manywithfieldMeta: {"type": "text", "required": true, "readOnly": true}returns 200 and persists the forbidden combination;- a field created legal (
required: true) can be flipped illegal in one update that suppliesreadOnly: truein its replacement meta.
The documented rules are the same five Field Types pages quoted in #3290, and the runtime consequences are identical: the signer-facing validation error the sender never sees.
Cause
The per-field loop runs exactly four checks (field exists, recipient exists, canRecipientFieldsBeModified, meta/type match) and writes updateData.fieldMeta straight to tx.field.update. No call to the configuration validators, which after #3293 exist as a reusable validateFieldMetaConfiguration.
Suggested fix
Run validateFieldMetaConfiguration(fieldType, field.fieldMeta) in the same loop — the effective type is already computed (field.type || originalField.type), and only the provided meta needs validating, because the update replaces it wholesale (an omitted meta keeps the stored one, per #3286/#3289). Reject with AppError(AppErrorCode.INVALID_REQUEST) so the API answers 400, mirroring #3290's create-path fix.
Suggested labels
type: bug
Found while reviewing #3293's coverage; the same audit reasoning as #3290 applies.
Source: documenso/documenso