🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

Passkey

by @ivangdavila

Implement WebAuthn passkeys avoiding critical security and compatibility pitfalls.

Versionv1.0.0
Downloads1,322
Stars⭐ 2
TERMINAL
clawhub install passkey

πŸ“– About This Skill


name: Passkey description: Implement WebAuthn passkeys avoiding critical security and compatibility pitfalls. metadata: {"clawdbot":{"emoji":"πŸ”","os":["linux","darwin","win32"]}}

Security-Critical Rules

  • Challenge must be unique per ceremony β€” reused challenges enable replay attacks
  • Origin validation is mandatory β€” missing check allows phishing from similar domains
  • Store and verify sign count β€” detects cloned authenticators when count doesn't increment
  • Never implement CBOR parsing manually β€” use established libraries, crypto is hard
  • Server Implementation

  • Use battle-tested libraries β€” SimpleWebAuthn (JS), py_webauthn (Python), webauthn-rs (Rust)
  • Challenges expire quickly β€” 60-120 seconds max, store server-side
  • Store credential ID as base64 β€” binary data, needs encoding for database
  • Store public key in COSE format β€” libraries handle this, don't transform it
  • Credential Storage Requirements

  • Credential ID β€” unique identifier, used in allowCredentials
  • Public key β€” COSE format, for signature verification
  • Sign count β€” integer, increment check detects cloning
  • Transports hint β€” helps browser suggest correct authenticator
  • Registration Traps

  • userVerification: "required" enforces biometric/PIN β€” "preferred" may skip verification
  • Attestation usually unnecessary β€” requiring it reduces device compatibility
  • Allow multiple passkeys per account β€” users have multiple devices
  • Resident key capability varies β€” don't assume all authenticators support discoverable credentials
  • Authentication Traps

  • Empty allowCredentials enables discoverable credentials β€” but not all passkeys are discoverable
  • Timeout too short frustrates users β€” 120 seconds minimum for cross-device flows
  • Cross-device auth (QR code) adds latency β€” don't timeout during Bluetooth handshake
  • User Experience

  • Provide password fallback β€” not all users have passkey-capable devices
  • Conditional UI (mediation: "conditional") for autocomplete β€” passkeys appear in username field
  • Clear messaging on registration β€” users don't understand "security key" terminology
  • Account recovery path required β€” hardware loss shouldn't lock out account forever
  • Platform Sync Behavior

  • Apple iCloud Keychain syncs across Apple devices β€” but not to Android/Windows
  • Google Password Manager syncs Android + Chrome β€” but not to Apple devices
  • Windows Hello is TPM-backed, local by default β€” doesn't sync
  • 1Password/Bitwarden provide cross-platform sync β€” broadest compatibility option
  • Testing

  • Chrome DevTools > Application > WebAuthn β€” simulate authenticators without hardware
  • Virtual authenticators in CI β€” no physical keys needed for automated tests
  • Test both resident and non-resident credentials β€” different flows
  • Cross-browser testing essential β€” Safari, Chrome, Firefox implementations vary