Password field autocomplete

Password fields on the page either try to disable autocomplete, which browsers ignore and password managers dislike, or lack the autocomplete tokens that let password managers fill and generate credentials safely.

Do this: Use autocomplete="current-password" so managers fill correctly. Blocking autocomplete pushes people towards simpler passwords they can retype, which is worse.
PassPassword fields use standard autocomplete tokens.
InfoPassword fields disable autocomplete or lack standard autocomplete tokens.

The fix, in one snippet

Example to adapt Let managers work
<input type="password" name="password" autocomplete="current-password">

Illustrative values. Change the paths, hostnames and options to match your own site before using it.

The sections below explain what is tested, why it matters and the alternatives.

What we test

Scan.now finds every <input type="password"> on the homepage and any form it links to as a login or sign-up page, and reads the autocomplete attribute on the field and its form. It reports three states as information: the attribute is absent (acceptable, browsers apply heuristics); it is set to off (noted, because Chrome, Firefox, Safari and Edge all ignore off on login fields and it merely interferes with password managers); or it uses the standard tokens current-password or new-password (best practice). It also checks whether the accompanying username or email field is marked autocomplete="username", and flags any onpaste handler or readonly trick intended to block pasting. This check is informational: it concerns usability and phishing resistance rather than a server-side weakness.

Why it matters

Password managers are one of the most effective defences ordinary users have. They generate long unique passwords, they only offer to fill on the origin where a credential was saved, so a lookalike domain gets nothing, and they remove the temptation to reuse. Anything that fights the manager pushes users toward weaker, reused, retyped passwords. autocomplete="off" on a login form has been ignored by all major browsers for years precisely because the "security" it promised was illusory and the cost was real. Getting the tokens right does more than avoid harm: new-password tells the browser to offer a generated password on registration and change-password forms and not to fill the old one there, and username lets the manager save the pair correctly. NIST SP 800-63B advises that verifiers should permit paste, for the same reason. The password managers guide and password security guide give the user-side view.

How to fix it

Login form:

<form method="post" action="/login">
  <input type="email" name="email" autocomplete="username" required>
  <input type="password" name="password" autocomplete="current-password" required>
  <button>Sign in</button>
</form>

Registration or change-password form:

<input type="email" name="email" autocomplete="username">
<input type="password" name="new_password" autocomplete="new-password">
<input type="password" name="confirm" autocomplete="new-password">

Django forms, setting the attribute on the widget:

password = forms.CharField(
    widget=forms.PasswordInput(attrs={"autocomplete": "current-password"}))

Remove any onpaste="return false" or JavaScript that clears pasted values. Keep the username field visible on the same page as the password field, even in a two-step flow (a hidden autocomplete="username" input on step two is fine), so the manager can associate them. If a compliance requirement seems to demand disabling autocomplete, read it again: it almost always targets card data or one-time codes, which take autocomplete="cc-number" and one-time-code respectively, not passwords.

Where this fits

Password field autocomplete is check 9 of 10 that the website vulnerability scanner runs under page content and javascript, ordered the way they are worth fixing. That ordering is the point: Fixing this one while the check above it still fails buys less than it looks like.

Fix this one first

Above it in the same category sits Inline event handlers and scripts (info), where the page relies on inline scripts, on* event-handler attributes or javascript: URLs. An attacker who has that does not need this, so it is the better use of the same hour.

What fixing this still leaves open

Password field autocomplete closes one route in. The next one down is Third-party script inventory, where an inventory of every script the page loads from other domains.

Found in the same scan

The website vulnerability scanner reports this alongside checks from other categories that are at least as serious, including Certificate chain and hostname validation, where the certificate presented for this hostname did not validate: The chain does not reach a trusted root, an intermediate is missing, the name does not match, or the certificate is self-signed or expired, and Exposed .env configuration file, where a .env configuration file is served from the web root. A single run of website vulnerability scanner answers all of them at once.

Prompt for an AI Hand this check to an assistant Sign in to copy it
The first few lines
You are a senior web engineer. I ran a security and SEO scanner against my site and it reported the finding below. Fix it properly rather than suppressing the symptom.

Finding: Password field autocomplete (info severity)
Scanner check id: autocomplete-password-fields
17 more lines, including the evidence and the exact fix

The rest of this prompt names the pages and line numbers we found the problem on, the configuration to change, and the constraints a good answer has to respect. It is free, it just needs an account so the work is not scraped wholesale.

Sign in with Google

Signing in is free and takes one click. We store your email address and nothing else.

References

  1. MDN: HTML autocomplete attribute
  2. web.dev: Sign-in form best practices
  3. NIST SP 800-63B: Digital Identity Guidelines, Authentication

Related guides