如何防止客户端脚本在从浏览器发送 API 请求之前更改 API 请求?

How to prevent client-side scripts from altering API requests before they are sent from the browser?

提问人:alex 提问时间:3/24/2023 更新时间:3/24/2023 访问量:12

问:

我不确定这是否是一个有效的问题,但我想知道它在您可能购买东西的网站上是如何工作的。

例如:我在亚马逊上 - 我决定要买一块手表。我将其添加到我的购物车中,然后单击“购买”。当我这样做时 - 一些恶意客户端脚本尝试执行以下操作:更新信息以添加项目,或将项目更改为其他内容。

假设它这样做,并将一本书的 1 个项目添加到某个随机供应商。即使有服务器端验证,亚马逊回来要求我在购买前确认,恶意客户端脚本也可以改变该页面的外观,并将其从书中擦除并调整“总”价格,使其看起来只是我买的手表,但服务器的东西我买的是手表+书。

下面是一个摘要/视觉对象:

1. Customer adds a watch to their cart
        |
        v
2. Malicious script adds a book to the cart
        |
        v
3. Customer proceeds to checkout and reviews the order
        |
        v
4. Malicious script alters the display of the checkout page
   (hides the book and adjusts the total price)
        |
        v
5. Customer confirms the order, unaware of the hidden book

在客户端/服务器端使用什么方法来防止这种情况发生?

安全 Web API 安全

评论


答: 暂无答案