Skip to content
All posts
4 min read

Not every secret belongs in a keychain

A share password is a secret I hand to someone else, so no browser should file it as their credential for my site. The gate fields on my site are masked text inputs, not password inputs.

EngineeringSystems

The field where I mint a share password is the best argument I know against type="password".

Here is what happens in it. I open the share editor in the admin, type a password into the box, click Set, and the share is locked. That password is not mine in any useful sense. It exists so I can send it to one person, in a different message than the link itself. But to the browser it is a password field on remielshirazi.com, typed by someone signed in to remielshirazi.com, so the save heuristics fire and the keychain offers to remember it as my credential for this site. That offer is right for a login form and wrong here, and the browser has no way to tell the difference.

So the gate fields on my site are not password fields. They are text inputs masked with CSS. The whole primitive is 38 lines in src/ui/primitives/stealth-password.tsx:

export function StealthPassword({ className, ...props }: InputHTMLAttributes<HTMLInputElement>) {
  const [fallback, setFallback] = useState(false);
  useEffect(() => {
    if (!CSS.supports("-webkit-text-security", "disc")) setFallback(true);
  }, []);

  return (
    <Input
      type={fallback ? "password" : "text"}
      autoComplete="off"
      data-1p-ignore=""
      data-lpignore="true"
      data-bwignore=""
      className={cn(!fallback && "[-webkit-text-security:disc]", className)}
      {...props}
    />
  );
}

type="text" means the credential heuristics never fire. -webkit-text-security: disc means the characters still render as dots, so nobody reads the secret over your shoulder. The three data attributes are the opt-out flags that 1Password, LastPass and Bitwarden look for. None of that is clever. The only line worth arguing about is the effect.

the fallback is the actual decision

-webkit-text-security is not universally supported. On a browser that lacks it, a text input renders the secret in plain readable characters, which is a much worse outcome than a save prompt. So the component asks at mount, and if the answer is no it turns into a real password field and accepts the keychain nagging.

That is the whole ranking, decided once and in advance: visible masking beats prompt suppression. The check sits in a useEffect, so the server renders the same markup either way and the swap happens only after mount, on the browsers that need it. The feature detection is the easy half. Deciding which of the two failures you would rather ship is the half that makes it a fallback instead of a bug report waiting to happen.

three of the fields are mine, two are not

There are five call sites: the admin login form, the share editor, the panel link editor, the share unlock screen at /s/[id], and the bot panel gate at /b/[id]. The first three I type into myself. The last two are typed by whoever I sent a link to.

For those two the argument gets sharper. A person lands on a lock screen, types the password I sent them separately, and gets in. If the browser offers to save that, the secret lands in someone else's keychain filed under my domain, labeled as though they hold an account here. They do not. The share expires, or I rotate the password, and the saved entry outlives both, pointing at a door that no longer opens.

What I gave up for this is real. A type="password" input comes with platform behavior attached: reveal buttons where the OS provides them, correct semantics for assistive tech, sane handling in managers people actually rely on. A masked text input has none of it by default. So every call site passes an explicit aria-label ("Share password", "Link password"), the gates take focus on mount, and the failure copy distinguishes a wrong password from a rate limit instead of collapsing both into one shrug. I traded a platform affordance for a rule about where secrets are allowed to live, and then rebuilt the small parts by hand.

the box is the least important part

Nothing above protects the share. That work happens on the server. The password is stored as scrypt with a per-secret random salt, serialized as scrypt$N$r$p$salt$key with N=16384, r=8, p=1 and a 32 byte key, and verified in constant time. It travels in a POST body and never in a URL. Unlock attempts are capped at 10 failures per IP per 15 minutes, with a second cap of 200 per share in the same window, because forwarding headers can be spoofed into minting fresh per-IP buckets and the per-share number is the backstop. A correct password sets an httpOnly cookie holding a signed grant that is good for 24 hours and bound to both the share id and a fingerprint of the current hash, so changing or removing the password silently revokes every grant already handed out.

The masking helps with none of that. It addresses a different failure, the one where a secret quietly accumulates copies: in a keychain, in a synced vault, on three of that person's devices, long after the thing it opened stopped existing. Rate limits do not help there. Neither does scrypt.

Password managers are good and I use one for everything that is genuinely an account. But their instinct is to save anything shaped like a credential, and a gate secret is shaped exactly like one while being nothing like one. Sometimes the right answer to "save this password?" is no, and the only way to get that answer every time is to stop the browser from asking.

Remiel Shirazi

CTO & Co-founder | AI, Roblox & Piano