简体   繁体   English

html5输入“必需”是一种安全的验证技术吗?

[英]is html5 input 'required' a secure validation technique?

I am concerned about web security and the use of the HTML5 required word on input tags. 我担心网络安全以及在输入标签上使用HTML5 required单词。 I am trying to use it as part of 'form input validation'. 我正在尝试将其用作“表单输入验证”的一部分。 Is the use of the HTML5 'required' on input tags something that is reliable for validation or is it easily manipulated by a user trying to bypass the input field requirement. 在输入标签上使用HTML5是“必需的”,这对于验证是可靠的,还是用户试图绕过输入字段要求而容易操纵的操作。

I have searched for information on html security and found little on this. 我已经搜索了有关html安全性的信息,但对此却鲜有发现。

Thanks 谢谢

In short, the answer is no, client side code is not a safe place to rely on security checks. 简而言之,答案是否定的,客户端代码不是依靠安全检查的安全场所。

The method of using required provides the user with feedback and allows for a nicer user interface, but for security you will want to perform fidelity checks on all data passed over to the server side, how that is done depends on your backed architecture. 使用required的方法可以为用户提供反馈,并提供更好的用户界面,但是出于安全性考虑,您将希望对传递给服务器端的所有数据执行保真度检查,具体如何执行取决于所支持的体系结构。

To answer your question in the comments, the required attribute is there to prevent the form being submitted without the field being complete, this is however purely to help the user know it is required. 要在评论中回答您的问题, required属性是为了防止表单没有完整填写的情况下提交表单,但这纯粹是为了帮助用户知道它是必需的。 If you have a hacker simply remove the required attribute from the markup, then they're up to no good anyway and that's where a backend check will save you. 如果您有一个黑客,只是从标记中删除了required属性,那么无论如何它们都是不好的,这就是后端检查将为您节省的地方。

In my Opinion it is not an effective method. 我认为这不是一种有效的方法。 Required attribute can easily be changed using inspect element on that field on the browser. 可以使用浏览器上该字段上的inspect元素轻松更改必填属性。 The main thing here is to keep in mind that all client side validation is your first line of defense but most of the time you need an extra layer to check on your server side. 这里最主要的是要记住,所有客户端验证都是您的第一道防线,但是大多数时候,您需要在服务器端进行检查的额外层。 I could make an http post request to the action field of your form without using your form at all with tools like postman (chrome extension) if your server doesnot have extra validation then you are not safe. 如果您的服务器没有额外的验证,那么我可以向表单的操作字段发出http发布请求,而无需使用邮递员(chrome扩展名)之类的工具,而根本不使用表单,那么您就不安全了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM