计算前端不安全的价格? [英] Calculate price on frontend insecure?

查看:119
本文介绍了计算前端不安全的价格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能操纵在前端进行的价格计算?我读了很多关于JavaScript价格计算器的信息,这些价格计算器仅在客户端具有业务逻辑,而对于安全性却一无所知。

I wonder if it would be possible to manipulate a price calculation that is done on the frontend? I read a lot about JavaScript price calculators with the business logic solely on the client side, but nothing about security.

请考虑以下情形:


  • React应用程序具有一个组件(窗体),该组件根据其子组件(窗体输入)的状态(用户交互)来计算价格。

  • 这些子组件的价格来自API。

  • 但是计算由父组件处理-在前端。

是否可以通过表格发送可操纵的计算结果?

Is it possible to send a manipulated calculation result through the form?

推荐答案

是的,仅客户端计算(不进行服务器端验证)是不安全的。

很遗憾,您的( clinet-side)形式可以发送,不足以防止操纵。这是因为HTTP请求可以通过各种不同的方法发送,而不仅仅是从您构造的形式发送。

Unfortunately restricting the values that your (clinet-side) form can send is not sufficient to prevent manipulation. This is because HTTP requests can be sent by all sorts of different methods, not just from the form that you construct.

要绕过此保护措施,攻击者只需检查您对服务器的API请求(例如,通过使用Chrome或Firefox中的开发人员工具),然后重新发送请求,并更改计算值。 Firefox的开发人员工具甚至具有编辑并重新发送功能,该功能专门允许您执行此操作(它也具有调试和测试API的合法用途)。

To bypass this protection all an attacker need do is inspect your API request to the server (for example by using the developer tools in Chrome or Firefox), and resend a request with the calculated value changed. Firefox's developer tools even have a feature "Edit and Resend" which specifically allows you to do this (it also has legitimate uses for debugging and testing APIs).

可以控制服务器环境吗?如果这样做,为什么不希望在那里进行验证?如果您告诉我们更多有关您的设置的信息,那么我们也许可以帮助您找到解决问题的好方法:)

Do you not have control of the server environment? And if you do, why do you not want to implement the validation there? If you tell us a little more about your setup, then we may be able to help you come up with a good solution to your problem :)

这篇关于计算前端不安全的价格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆