Commit c5b2917
[Security] Harden Serialize::unserialize() callers and deprecate the permissive default (pimcore#19293)
* [Security] Make Serialize::unserialize() safe by default
Serialize::unserialize() defaulted its allowedClasses argument to true, so every
single-argument caller permitted arbitrary PHP object deserialization. Flip the default
to false (no object instantiation) and pass an explicit argument at every existing caller:
- callers that only handle scalars/arrays now pass false;
- callers that reconstruct known stored value objects pass a scoped allowlist
(e.g. Geopolygon/Geopolyline -> GeoCoordinates);
- callers that reconstruct open, user-defined object graphs (element versions, recycle
bin, session elements, encrypted fields, and object field data) pass an explicit true,
to be scoped further as a follow-up.
Also restrict two raw unserialize() calls (a CoreBundle migration and the SeoBundle
controller) to allowed_classes => false.
Adds tests/Unit/Tool/SerializeTest.php covering the safe default, explicit allowlist,
explicit true, and scalar/array round-trips.
Co-Authored-By: Claude <noreply@anthropic.com>
* Keep Serialize::unserialize() default as-is and deprecate omitting the argument
Reverts the default flip (true -> false) to preserve backward compatibility: the
wrapper is public, non-@internal API, so changing its default behaviour on a minor
line would silently break external callers that rely on it to reconstruct objects.
Instead, keep the default `true` and emit a deprecation when the $allowedClasses
argument is omitted, so callers migrate to an explicit value. The default will be
switched to `false` in Pimcore 2027.1. The per-caller hardening (explicit arguments
at every core call site) and the raw-unserialize() fixes are unchanged and remain the
actual security improvement.
Co-Authored-By: Claude <noreply@anthropic.com>
* Add upgrade note for the Serialize::unserialize() deprecation
Documents the deprecation of the permissive default under the next 12.3 patch, matching
the repository's upgrade-notes convention (deprecation + the 2027.1 removal target).
Co-Authored-By: Claude <noreply@anthropic.com>
* Emit the unserialize() deprecation once per process + cover geo datatypes in blocks
Addresses review feedback:
- Serialize::unserialize() emitted the "$allowedClasses omitted" deprecation on every call,
which could flood the logs when unserializing in a loop (e.g. a listing of many objects).
Guard it with a static flag so it fires at most once per process. The unit test now asserts
a second omitting call stays silent.
- Add geo child fields (geopoint, geobounds, geopolygon, geopolyline) to the test block and a
BlockTest case that round-trips all four inside a block, proving Block::getDataFromResource()'s
`Serialize::unserialize($data, false)` does not neutralise geo values (they are stored
normalized and rebuilt via each sub-field's denormalize()).
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d247aa6 commit c5b2917
19 files changed
Lines changed: 244 additions & 14 deletions
File tree
- bundles
- CoreBundle/src/Migrations
- SeoBundle/src/Controller
- doc/23_Installation_and_Upgrade/09_Upgrade_Notes
- lib
- DataObject/ClassificationstoreDataMarshaller
- Tool
- models
- DataObject
- ClassDefinition/Data
- Data
- Document
- Hardlink
- Element
- Recyclebin
- tests
- Model/DataType
- Support/Helper
- Unit/Tool
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
3 | 14 | | |
4 | 15 | | |
5 | 16 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
29 | 47 | | |
30 | 48 | | |
31 | 49 | | |
32 | 50 | | |
33 | 51 | | |
34 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
35 | 65 | | |
36 | 66 | | |
37 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
0 commit comments