Skip to content

Refuse a server auth-version-1 answer for an account pinned as v2 (Batch R) - #12

Merged
chogarcia merged 1 commit into
mainfrom
fix/auth-v2-downgrade-pin
Oct 12, 2026
Merged

chogarcia merged 1 commit into
mainfrom
fix/auth-v2-downgrade-pin

Conversation

@chogarcia

@chogarcia chogarcia commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Audit 2026-10-02, Batch R: web and mobile pin "this account is v2"; the CLI obeyed any server authVersion: 1 answer and posted the raw password.

Before: /api/auth/salt answering version 1 (tampered server, or an account downgraded via a stolen session) made sf login/push/sync send the raw password.

After:

  • After a sign-in that sent only the login secret, the account is recorded in ~/.shieldfive/auth-pins.json (SHA-256 of the lower-cased email, file 0600, dir 0700 via ensurePrivateDir, write-then-rename).
  • For a pinned account, a version-1 answer (migration on or off) throws LegacyLoginRefusedError (code: legacy_login_refused) before anything but the salt lookup is sent.
  • --allow-legacy-login on sf login, sf push, sf sync overrides; the pin is kept afterwards.
  • A failed pin write does not fail sign-in. An unreadable/corrupt pin file reads as no pins and is replaced on next write.
  • signIn() takes optional authPin / allowLegacyLogin; library callers without authPin behave as before.

Tests: new test/auth.pin.test.mjs (8). npm test: 144/144 pass.

Not published; release is the founder's call. CHANGELOG has an Unreleased entry.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

After a sign-in that sent only the login secret, record the account
(SHA-256 of the email) in ~/.shieldfive/auth-pins.json, 0600 in a 0700
dir. A later version-1 answer for it throws LegacyLoginRefusedError
before the raw password is posted, unless --allow-legacy-login is passed
to sf login, push or sync. Mirrors the mobile and web pins (audit
2026-10-02, Batch R).
@chogarcia
chogarcia merged commit 938e282 into main Oct 12, 2026
1 check passed
@chogarcia chogarcia mentioned this pull request Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant