[security] Mass assignment fix sweep
fix: [security] Mass assignment fix sweep
[security] Mass assignment fix sweep3ff6bd-fix-security-mass-assignment-fix-sweep-cve-2026-56422fixsecurity mass assignment fix sweep
Committed by iglocska
commit message
fix: [security] Mass assignment fix sweep
Mass-assignment audit Tier B #7 — TemplateElementsController. LIVE,
REST-reachable, perm_template (lesser-user) id-redirection in the nested
sub-element save of add() and addV2().
Both add($type,$id) and addV2($id) create a fresh base TemplateElement
(template_id forced to the route-authorised template) and then save the
type-specific sub-model (TemplateElementAttribute / TemplateElementText /
TemplateElementFile) straight from $this->request->data. They force the
sub-model's template_element_id to the new base element but never strip
id; create() before save() does NOT strip a supplied primary key, and the
sub-models have no beforeSave/id-guard. So an injected
TemplateElement<Type>[id] turns the INSERT into a covert UPDATE that
re-parents (via the forced template_element_id) and overwrites an
arbitrary element row owned by another org's template.
Unlike TemplatesController this controller has NO beforeFilter clobber of
the REST unlockedActions, so parent::beforeFilter() leaves the action
REST-unlocked and SecurityComponent field-hashing does not apply on the
REST path — the hole is live, not preventative.
Fixed by unsetting the sub-model id before create()+save() in both add()
and addV2() (edit()/editV2() already pin it to the loaded row).
Verified live as lesser user 184 (org 156, perm_template, NOT site-admin)
via REST POST /template_elements/add/attribute/<own-template-id> with an
injected TemplateElementAttribute[id]=1: pre-fix the victim attribute
(template 1, org "MISP", "From address") was overwritten and re-parented
onto the attacker's template (template_element_id moved, name/to_ids
overwritten); post-fix the same request left the victim untouched and
inserted a fresh row under the attacker's own template. DB restored,
test artifacts cleaned.
Other actions SAFE: edit()/editV2() pin sub-model id + template_element_id
to the loaded record (no redirection); delete() loads by route id and
deletes the loaded sub-model/base ids; deleteSelection checkModifyCallback
returns perm_site_admin (SAFE gate, not DPT-1); index/templateElementAddChoices
read-only.
Out of mass-assignment scope, flagged for the post-sweep follow-up
(PRD §12 DPT-5): edit($type,$id) authorises checkAuthorisation($id, ...)
where $id is the template ELEMENT id, but checkAuthorisation expects a
TEMPLATE id (wrong-entity authz, the DPT-3 class). editV2 does it right
(authorises the loaded element's parent template). Narrowly exploitable
(needs a coincidentally-id'd owned template) and the save id is pinned to
the loaded record, so it is broken-access-control, not mass-assignment;
left for the deferred ACL sub-project.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>Editor assessment
This commit patches CVE-2026-56422. The body names TemplateElementsController, explains that add() and addV2() save a type-specific sub-model without stripping id, and contrasts it with the controller lacking the beforeFilter clobber, so the hole is live rather than preventative. The unset before create is a clear remedy, and the attacker-user reproduction is concrete. Presentation is the weakness: roughly two thousand characters, many internal abbreviations, and a closing out-of-scope note about authz that belongs in a ticket. The generic sweep subject also fails to point at the affected controller.