如何防止ajax中的远程表单发布?
如何限制我在 ajaxRequest.open 中使用的 php 文件通过特定页面访问?
我想使用会话之类的东西来防止远程表单发布,因为可以通过这种方式检查许多猜测的用户名密码。
我知道检查引荐来源网址并不是一个安全的想法。 基于IP的自动封锁安全吗?
检查它是否是通过 Ajax 发布的,如果不是则因为没有人可以通过 Ajax 远程发布而拒绝它,这是一个好主意吗?真的安全吗?
提前致谢
How can I limit my php file that I use in ajaxRequest.open to be accessed through specific pages?
I want to use something like sessions to prevent remote form posting becuase many guessed passwords for a username can be checked through this way.
I know checking referrer is not a secure idea.
Is auto blocking based on IP a secure one?
Is it a good idea to check if it is posted through Ajax and if not deny it because no one can remote post through Ajax? Is it really secure?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你把事情搞混了。 AJAX 依赖于 HTTP 协议(例如:
POST
、GET
)来工作。因此,使用 AJAX 将不会阻止人们伪造查询。有一个名为HTTP_X_REQUESTED_WITH
的标头,但与来自客户端的任何内容一样,它不应该被信任。对远程 AJAX 发布的担忧更多地与称为跨站点远程伪造(CSRF)的漏洞有关< /a>.防止这种情况的一种方法是使用 CSRF 令牌(阅读 wiki 页面)。您(似乎)描述的问题是另一回事。
在处理登录时,我喜欢实现不同的失败阈值:
如果您尝试登录帐户并失败 X 次,您将收到验证码。这将防止人们使用机器人暴力破解密码,而不会给(太多)合法用户带来不便。
如果您失败 X+Y 次,该帐户将被锁定 Z 时间。
如果看起来有很多失败的登录来自您的 IP,它将被阻止。
You are mixing things up. AJAX relies on the HTTP protocol (eg:
POST
,GET
) to work. So using AJAX will not stop people from forging queries. There is a header calledHTTP_X_REQUESTED_WITH
, but like anything coming from the client, it should not be trusted.The concern about remote AJAX posting is related more to an exploit known as Cross-site remote forgery, or CSRF. One way to prevent this is by using CSRF tokens (read the wiki page). The problem you (seem to be) describing is something else.
When dealing with logins, I like to implement different failure thresholds:
If you are trying to login to an account and fail X times, you will be greeted with a CAPTCHA. This will prevent people from using bots to brute force a password, without inconveniencing (too much) legitimate users.
If you fail X+Y times, the account will be locked for a Z amount of time.
If it looks like a lot of failed logins are coming from your IP, it will be blocked.