Entities 0.2.11: Crafted form data can no longer break a record
Entities 0.2.11 closes a set of holes where a crafted request could store a value that made a record impossible to display, or crash the public form before any check ran.
A text, text area or rich text field could be sent a structured value instead of text. It was saved, and from then on every page showing that record crashed for every viewer, with no fix short of editing the database. Such values are now dropped when they enter the form and refused when saved, from the admin, the embedded form and the public form alike. The “Other” answer of choice fields must now be text too, and the embedded form no longer takes file, image or relation values from a submission.
The read-only view now shows an odd stored value as plain text instead of crashing, so records already affected can be opened again.
The public form, which needs no sign-in, also crashed with a server error on four kinds of malformed requests before its checks ran. They are now treated as empty values, as are malformed autosave and submit messages in the embedded form.
Full release notes: Entities 0.2.11
0.2.11 · 6 August 2026
Fixed
- Crafted
datapayloads could store a non-scalar value that then permanently broke rendering for a record.LiveDataForm.whitelist_known_fields/2filtered submitted params by key only, andFormBuilder.validate_type/2‘s catch-all accepts any term for the types it doesn’t special-case, so a map (or a list of maps) could land under atext/textarea/rich_textkey. Every surface that renders one stringifies it naively —to_string/1in the readonly view, bare{@value}inside<textarea>in the edit form — and both raiseProtocol.UndefinedErroron a map, crashing the page for every subsequent viewer with no fix short of a manual DB edit. Closed at two layers: a new per-field-type value-shape gate (LiveDataForm.sanitize_values/2) drops a mis-shaped value at the point data enters the component, leaving the previously-stored value intact, andEntityData.changeset/2— the final, caller-independent word on what lands indata, also reachable from the adminDataFormand the public form — now rejects a non-scalar for those types outright. (#25) - The
allow_otherescape hatch accepted any term as a “custom” answer.EntityData.validate_choice_field/3andvalidate_checkbox_field/3, plusFormBuilder.validate_type/2’s checkbox clause, waved through any out-of-options value onceallow_otherwas set — a map included.allow_othermeans one free-text custom entry, so an out-of-options value (or list element) must now also be a binary. This path is reachable from the public, unauthenticated form, where the changeset is the only gate. (#25) - A malformed
"autosave"/"submit"payload crashed the whole LiveView process, not just the component.%{"phoenix_kit_entity_data" => data_params}constrains only the outer payload, so a craftedpushEventTowith a non-mapdata_paramsreachedMap.get/3and raisedBadMapError; a present-but-non-map"data"value raised the same way insidenormalize_absent_checkboxes/2. Both now fall through to the existing empty-autosave clause. (#25) - The error message that rejects a bad checkbox value crashed while being built.
Enum.join(invalid_values, ", ")in bothEntityData.validate_checkbox_field/3andFormBuilder.validate_type/2calledto_string/1on the very non-binary term the new guards route into that list — trading a stored bad value for an attacker-triggeredProtocol.UndefinedError. NowEnum.map_join/3with aninspect/1fallback. (#25) filefields were the one field type both new shape gates missed, and they are rendered. Nothing in this library producesfiledata (thebuild_field/3clause is an upload placeholder), so every value under afilekey arrives from outside — including the unauthenticated/entities/:entity_slug/submitPOST when the field is listed inpublic_form_fields. A stored map reachedLiveDataForm’s readonly catch-all (to_string/1), and a stored list of plain strings reachedfile["filename"]in the edit form, where the Access syntax raisesFunctionClauseErroron a binary — the same permanent, un-renderable record the rest of this release closes.LiveDataFormnow drops values submitted underfile/image/relationkeys (none render a submittable input), andFormBuilder.build_field/3’sfileclause skips non-map entries. (#25 follow-up)LiveDataForm’s readonly view now degrades instead of raising on any already-stored value. The write-side gates above only govern new writes — rows poisoned before them, rows written by a parent app callingEntityDatadirectly, and anything under afilekey still hold whatever they hold, and the readonly view is where those get rendered.readonly_text/1,readonly_value/1,readonly_list/1’s join and theselect/radioclause (whosetranslated_option_label/3deliberately falls back to the raw stored value) all route through a totalsafe_string/1—inspect/1for anything without aString.Charsimplementation. This is what makes an already-poisoned record viewable again. (#25 follow-up)- Four crafted-payload crashes in the public form controller, all reached before the changeset gate.
EntityFormController.submit/2is un-authed by design, so the whole body is attacker-shaped and nested params arrive as maps:get_in(params, ["phoenix_kit_entity_data", "data"])raised on a non-mapphoenix_kit_entity_data, a non-map"data"hitmerge_other_params/2’sis_map/1clause head, a map undername/title/subject/emailreachedString.downcase/1viagenerate_slug/1, and a non-string_form_loaded_atreachedDateTime.from_iso8601/1inside the security-check phase. Each was an unauthenticated 500 beforeEntityData.changeset/2— the gate this path relies on — ever ran. All four now degrade to the ordinary empty/absent-value path. (#25 follow-up) - Removed eight orphaned
mix.lockentries (igniter,sourceror,rewrite,spitfire,owl,glob_ex,ex_ast,text_diff) left by the previous dependency bump, which hadmix deps.unlock --check-unused— and thereforemix precommit— failing onmain. test/phoenix_kit_entities/html_sanitizer_test.exsno longer pins the exact byte output ofPhoenixKit.Utils.HtmlSanitizer(a dependency). The upgraded sanitizer addsrel="noopener noreferrer"to links and inserts the implied<tbody>in tables — both upstream hardening, not regressions — which had two tests failing onmain. They now assert that the element and its safe attributes survive.
Entities 0.2.11. Install or update: {:phoenix_kit_entities, "~> 0.2"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.