从我目前了解到的情况来看,令牌的目的是防止攻击者伪造表单提交。
例如,如果一个网站有一个表单,可以将添加的商品输入到您的购物车中,攻击者可以向您的购物车发送垃圾邮件,其中包含您不想要的商品。
这是有意义的,因为购物车表单可能有多个有效输入,攻击者所要做的就是知道网站正在销售的商品。
我了解令牌是如何工作的,并在这种情况下增加了安全性,因为它们可以确保用户实际填写并按下添加到购物车中的每个项目的表单的“提交”按钮。
但是,令牌是否为需要用户名和密码的用户登录表单增加了任何安全性?
由于用户名和密码非常独特,攻击者必须知道这两个信息才能伪造登录(即使您没有设置令牌),如果攻击者已经知道这一点,他可以自己登录网站。更不用说,让用户自己登录的CSRF攻击无论如何都不会有任何实际目的。
我对CSRF攻击和令牌的理解是否正确?正如我所怀疑的那样,它们对用户登录表单毫无用处吗?