使用 CakePHP 的 Json 数据类型会出现哪些漏洞问题?

What vulnerability issues can occur using CakePHP's Json Data Type?

This page 表示:

When using complex types it is important to validate that the data you are receiving from the end user is the correct type. Failing to correctly handle complex data could result in malicious users being able to store data they would not normally be able to.

当从前端接受 JSON 数据时,实际上会发生什么坏事(知道 CakePHP 在后台执行其标准安全检查)?

CakePHP 开发人员在处理 JSON 输入 单列 并依赖于上面引入的对 JSON 列类型?

大多数情况下,问题在于拥有正确的结构和连贯的数据。

例如,如果您存储了来自用户的序列化数据,并且您希望它是一个像这样的整数列表:

[1, 4, 5, 6]

因此您可以在应用程序的任何部分执行 array_sum($values)。有人可能会提交一个像这样的数组

[{a: 2}, {s: 15}, {}, 'hello']

在这种情况下调用 array_sum() 会给你警告。

根据您在结构和数据类型方面的预期来验证您收到的信息很重要。