通过隐藏字段将模型 ID 传递给控制器​​安全吗?

发布于 2025-01-15 01:00:46 字数 163 浏览 3 评论 0原文

想象一下,我有一个采用员工类型模型的视图。员工定义如下: 员工{ ID 整数, 员工姓名字符串 } 如果我想更新数据库中的员工,我必须将模型传递给操作。 更新员工(员工 emp) 在隐藏字段中定义员工 ID 会存在安全风险,不是吗? 有人可以轻松地进入检查员并传递他们喜欢的任何 ID,并且该员工的信息将会更新。

Imagine I have a view that takes a model of type employee. Employee is defined like so:
Employee{
ID int,
Employee Name string
}
If I wanted to update an employee in the database I have to pass the model to the action.
UpdateEmployee(Employee emp)
Defining the employee ID in a hidden field would be a security risk wouldn't it?
Someone could easily go into the inspector and pass whatever ID they like and the information will be updated for that employee.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文