`` 阻止我登录 Vanguard。
prevents me from logging into Vanguard

原始链接: https://tanin.nanakorn.com/input-type-password-maxlength-20-is-considered-harmful-and-why-i-couldnt-login-into-vanguard/

用户登录 Vanguard 失败是由于长密码处理方式不一致。Vanguard 的密码重置表单设置了 `maxlength="20"`,因此 Chrome 会在用户无感知的情况下,将 1Password 生成的 26 位密码截断为 20 位,并应用到两个密码字段中。重置使用截断后的密码成功完成。 然而,登录表单没有 20 位密码限制,因此 1Password 提交了完整的 26 位密码。Vanguard 将其判定为错误密码并拒绝登录,看起来像是密码重置失败。 这表明,密码字段中的 `maxlength` 可能在用户不知情的情况下修改输入内容。应当改为通过 JavaScript 或后端明确验证密码长度,确保提交的值与用户原本的输入一致。

Hacker News 上的一则讨论聚焦于 Vanguard 的登录表单会在 20 个字符后无提示地截断密码。密码管理器生成的较长密码看似保存成功,却无法登录。 reportedly mobile app accepts longer passwords, indicating inconsistent frontend validation rather than necessary backend restriction. 评论者强烈批评这种静默截断行为,尤其是在金融机构中。他们认为,网站应明确披露并统一执行合理的限制,或者允许使用较长的随机密码和口令短语。也有人为较短的限制辩护,因为 16 个字符的强随机密码已经极难破解,而且手动输入可能并不方便。 另一些人指出,bcrypt 会忽略输入中超过 72 字节的部分,但这个问题可以通过预哈希、现代密码哈希算法或较宽松的服务器请求大小限制来处理,而不是在用户界面上任意设置 20 个字符的上限。讨论还涉及密码管理器、通行密钥、银行合规要求、安全作秀,以及其他金融和消费网站上出现的类似问题。
相关文章

原文

For the longest time, I couldn't login to my Vanguard account through web.

I reset the password maybe 3 times during the past year, and it still didn't work. I didn't have time to think about it more, so I assumed there was a glitch. I'd just login by scanning the QR code with the Vanguard app on my phone.

Eventually, I've decided to spend some time figuring out, and maxlength="20" is the root cause. Let me explain.

Vanguard has the reset password form where <input type="password"> sets its maxlength to be 20.

I am using 1password with a heightened sense of security. Of course, my generated password is longer than 20 characters. I would copy the password and paste it in the password input field.

For simplicity, let's say my password is abcdefghijklmnopqrstuvwxyz (26 characters) Since the maxlength is 20, Chrome inputs only abcdefghijklmnopqrstu (20 characters) as shown below:

I'd paste the password twice. Once in the password field, and another in the confirm password field. Then, I'd would click submit.

All good. The password reset was a success!

Then, I'd go to the login page and try to login using the same password.

As it turns out, the password field on the login page doesn't set maxlength to 20. Therefore, the pasted password is the full abcdefghijklmnopqrstuvwxyz (26 characters) as shown below:

Vanguard would complain that my password was incorrect. And I would be so confused because I just reset the password.

This is one example why we shouldn't use the maxlength attribute on the password field. Validating the length using JS or on the backend seems superior since it processes the exact text that the user sends... not the unintentionally trimmed text.

联系我们 contact @ memedata.com