← Blog

Claude skill WebAuthn FIDO2 security — SA-SKL-WEBAUTHN

WebAuthn and FIDO2 passkey authentication is increasingly common in Claude MCP skills that offer passwordless login. The W3C specification is rigorous — but implementations routinely skip the most security-critical verification steps because the browser-side API looks deceptively simple. SkillAudit finds four consistent failure modes: attestation verification is skipped because it appears optional, the server-side challenge is never stored so any challenge value passes, the rpId in authenticatorData is accepted from any domain, and the sign counter is never checked so credential cloning goes undetected. WEBAUTHN-001 through WEBAUTHN-004 cover each with the specific spec reference, the vulnerable pattern, and a drop-in fix using @simplewebauthn/server.

By SkillAudit  |  5 Nov 2026

Why WebAuthn implementation errors are high-severity in MCP skills

An MCP skill that exposes a WebAuthn registration and authentication flow is acting as an identity provider. If the WebAuthn verification is incorrect, the skill grants authenticated sessions to unauthenticated parties. Unlike a weak password policy, which degrades authentication strength, a broken WebAuthn implementation can completely bypass authentication — an attacker who can replay a captured credential response, spoof an rpId, or submit fabricated attestation data gains the same access as a legitimate authenticator. The severity is compounded because WebAuthn is often adopted specifically to replace a weaker authentication mechanism; a broken passkey implementation provides less security than the password flow it was meant to replace.

SA-SKL-WEBAUTHN in scope: WEBAUTHN-001 (attestation verification skipped), WEBAUTHN-002 (challenge not stored server-side), WEBAUTHN-003 (rpId not validated), WEBAUTHN-004 (sign counter not checked). Each includes the W3C spec reference, SkillAudit detection rules, and fixes using @simplewebauthn/server which handles all four correctly by default.

WEBAUTHN-001 — Attestation verification skipped

During WebAuthn registration, the browser returns an attestationObject that contains a signed statement from the authenticator device (or the platform) vouching for the credential's provenance. Verifying this attestation requires checking the signature against the authenticator's attestation certificate chain, which ultimately chains to a root certificate in the FIDO Metadata Service (FIDO MDS). Many developers skip this step because: (1) the W3C spec marks attestation verification as optional for "none" format, (2) navigator.credentials.create() succeeds without it, and (3) the base64-encoded blob appears to work for authentication regardless. The result is that the RP accepts credentials from any source — including software authenticators that an attacker controls. An attacker can register a credential with fabricated attestation data that claims to be a hardware security key, and the RP stores it without verifying the claim. For high-assurance applications, this defeats the purpose of hardware-backed authentication entirely.

// VULNERABLE: attestationObject stored without verification
// Registration endpoint — skips attestation signature chain check
const { isoBase64URL, cbor } = require('@simplewebauthn/server/helpers');

app.post('/webauthn/register/verify', async (req, res) => {
  const { id, rawId, response: authResp, type } = req.body;

  // VULNERABLE: decodes attestation but never verifies the signature
  const attestationBuffer = isoBase64URL.toBuffer(authResp.attestationObject);
  const decoded = cbor.decode(attestationBuffer);

  // decoded.fmt could be 'packed', 'fido-u2f', 'tpm', 'android-key', etc.
  // VULNERABLE: trusts client-supplied credential without checking decoded.attStmt signature
  // An attacker can submit decoded.fmt = 'none' with any public key they control

  // Stores credential directly — no attestation verification
  await db.credentials.create({
    userId: req.session.userId,
    credentialId: id,
    publicKey: decoded.authData, // VULNERABLE: authData not fully parsed or verified
    counter: 0,
  });

  res.json({ verified: true }); // Always true — no actual verification
});
// FIXED: @simplewebauthn/server verifyRegistrationResponse() performs full attestation check
const {
  generateRegistrationOptions,
  verifyRegistrationResponse,
} = require('@simplewebauthn/server');

app.post('/webauthn/register/options', async (req, res) => {
  const options = await generateRegistrationOptions({
    rpName: 'SkillAudit',
    rpID: 'skillaudit.dev',
    userID: req.session.userId,
    userName: req.user.email,
    attestationType: 'direct', // 'none' | 'indirect' | 'direct'
    // For high-assurance: 'direct' requests attestation that can be verified
    // 'none' is acceptable for consumer use cases where device type doesn't matter
    authenticatorSelection: {
      residentKey: 'required',
      userVerification: 'required',
    },
  });

  // Store challenge server-side before responding (see WEBAUTHN-002)
  req.session.webauthnChallenge = options.challenge;
  await req.session.save();

  res.json(options);
});

app.post('/webauthn/register/verify', async (req, res) => {
  const expectedChallenge = req.session.webauthnChallenge;

  // Clear challenge immediately — single-use (see WEBAUTHN-002)
  req.session.webauthnChallenge = null;
  await req.session.save();

  let verification;
  try {
    verification = await verifyRegistrationResponse({
      response: req.body,
      expectedChallenge,                      // Server-generated, single-use
      expectedOrigin: 'https://skillaudit.dev', // Must match window.location.origin
      expectedRPID: 'skillaudit.dev',          // Must match rpId in options (WEBAUTHN-003)
      // requireUserVerification: true for high-assurance flows
    });
  } catch (err) {
    // verifyRegistrationResponse throws on any verification failure
    return res.status(400).json({ error: 'Verification failed' });
  }

  if (!verification.verified) {
    return res.status(400).json({ error: 'Not verified' });
  }

  const { registrationInfo } = verification;

  // Store credential with parsed, verified fields only
  await db.credentials.create({
    userId: req.session.userId,
    credentialID: registrationInfo.credential.id,
    credentialPublicKey: registrationInfo.credential.publicKey, // Verified COSE public key
    counter: registrationInfo.credential.counter,               // Initial sign counter (WEBAUTHN-004)
    transports: registrationInfo.credential.transports,
    aaguid: registrationInfo.aaguid, // Authenticator type for policy enforcement
    attestationFmt: registrationInfo.fmt, // For audit log
  });

  res.json({ verified: true });
});
HIGH
SA-SKL-WEBAUTHN-001 — MCP skill WebAuthn registration handler stores credentials without calling a library that verifies the attestation signature chain against the authenticator's attestation certificate and the FIDO Metadata Service root; raw decoding of attestationObject without signature verification allows an attacker to register a credential with fabricated attestation, defeating hardware-backed authentication guarantees. Fix: use @simplewebauthn/server verifyRegistrationResponse() which performs full attestation verification including signature chain check; pass expectedChallenge, expectedOrigin, and expectedRPID. Detection: SkillAudit flags WebAuthn registration handlers that decode attestationObject without calling an attestation-verification function.

WEBAUTHN-002 — Challenge not stored server-side

The WebAuthn challenge is the core replay-attack defense. The server generates a random 32-byte challenge, embeds it in the registration/authentication options, and later verifies that the challenge in the returned clientDataJSON matches the one it generated. This verification is only meaningful if the challenge is stored on the server and is single-use. Developers sometimes skip server-side storage because: (1) they treat the challenge like a CSRF token that can be regenerated from a known seed, (2) they store it client-side in a cookie, or (3) they trust the challenge value returned by the client in the POST body. If the challenge is not stored server-side, an attacker can replay a valid authentication response from a previous session — the RP has no stored challenge to compare against and must accept any challenge value. Combined with a stolen or cloned credential, this enables persistent authentication bypass.

// VULNERABLE: challenge generated but not stored server-side
app.get('/webauthn/auth/options', async (req, res) => {
  const challenge = crypto.randomBytes(32).toString('base64url');

  // VULNERABLE: challenge is returned to client but not stored server-side
  // On verify, the server has no stored challenge to compare against
  // An attacker can intercept a valid authentication response and replay it
  // by supplying the original challenge in a new POST to /webauthn/auth/verify

  res.json({
    challenge,  // Client receives this — but server forgets it immediately
    rpId: 'skillaudit.dev',
    timeout: 60000,
    userVerification: 'required',
  });
});

app.post('/webauthn/auth/verify', async (req, res) => {
  // VULNERABLE: trusts challenge from req.body or reconstructs from client-supplied data
  const clientData = JSON.parse(
    Buffer.from(req.body.response.clientDataJSON, 'base64').toString()
  );

  // VULNERABLE: no server-stored challenge to compare clientData.challenge against
  // Any challenge passes — attacker replays old authentication responses
  const expectedChallenge = clientData.challenge; // Trusting client's own challenge!
  // ... rest of verification uses this unverified challenge
});
// FIXED: challenge stored in server-side session, consumed on use (single-use)
const { generateAuthenticationOptions, verifyAuthenticationResponse } = require('@simplewebauthn/server');

app.get('/webauthn/auth/options', async (req, res) => {
  const userCredentials = await db.credentials.findAll({ userId: req.session.userId });

  const options = await generateAuthenticationOptions({
    rpID: 'skillaudit.dev',
    userVerification: 'required',
    allowCredentials: userCredentials.map(c => ({
      id: c.credentialID,
      transports: c.transports,
    })),
    timeout: 60000,
  });

  // FIXED: store challenge server-side — in session (tied to this user)
  // Use a session store with TTL matching the WebAuthn timeout
  req.session.webauthnChallenge = options.challenge;
  req.session.webauthnChallengeExpiry = Date.now() + 65000; // 5s grace over timeout
  await req.session.save();

  res.json(options);
});

app.post('/webauthn/auth/verify', async (req, res) => {
  const storedChallenge = req.session.webauthnChallenge;
  const challengeExpiry = req.session.webauthnChallengeExpiry;

  // FIXED: clear challenge BEFORE verification — single-use, prevents race-condition replay
  req.session.webauthnChallenge = null;
  req.session.webauthnChallengeExpiry = null;
  await req.session.save();

  if (!storedChallenge) {
    return res.status(400).json({ error: 'No pending challenge' });
  }

  if (Date.now() > challengeExpiry) {
    return res.status(400).json({ error: 'Challenge expired' });
  }

  const credential = await db.credentials.findOne({
    credentialID: req.body.id,
    userId: req.session.userId,
  });

  if (!credential) {
    return res.status(400).json({ error: 'Unknown credential' });
  }

  let verification;
  try {
    verification = await verifyAuthenticationResponse({
      response: req.body,
      expectedChallenge: storedChallenge, // Server-side, never client-supplied
      expectedOrigin: 'https://skillaudit.dev',
      expectedRPID: 'skillaudit.dev',
      credential: {
        id: credential.credentialID,
        publicKey: credential.credentialPublicKey,
        counter: credential.counter,  // For WEBAUTHN-004
        transports: credential.transports,
      },
      requireUserVerification: true,
    });
  } catch (err) {
    return res.status(400).json({ error: 'Verification failed' });
  }

  if (!verification.verified) {
    return res.status(400).json({ error: 'Not verified' });
  }

  // Update sign counter (WEBAUTHN-004)
  await db.credentials.update(credential.id, {
    counter: verification.authenticationInfo.newCounter,
  });

  req.session.authenticated = true;
  req.session.userId = credential.userId;
  await req.session.save();

  res.json({ verified: true });
});
CRITICAL
SA-SKL-WEBAUTHN-002 — MCP skill WebAuthn authentication handler does not store the server-generated challenge in server-side session storage before returning options to the client; without a server-stored challenge, the RP cannot verify that the authentication response corresponds to its own challenge request; an attacker who captures a valid authentication response can replay it indefinitely or supply an arbitrary challenge in the POST body. Fix: generate challenge with crypto.randomBytes(32) via generateAuthenticationOptions(); store it in server-side session with TTL matching the WebAuthn timeout; clear it immediately before verification (single-use); pass storedChallenge as expectedChallenge to verifyAuthenticationResponse(). Detection: SkillAudit flags authentication flows where the challenge is returned in the GET options response but no session write is observed before the GET handler returns.

WEBAUTHN-003 — rpId not validated in authenticatorData

The rpIdHash in the authenticatorData blob is a SHA-256 hash of the relying party ID (rpId) — typically the domain of the application. Its purpose is to bind the credential to a specific origin: a credential registered on evil.com cannot be used on skillaudit.dev because the rpIdHash will not match. This check must be performed on the server. If the RP accepts authenticatorData without verifying that rpIdHash === SHA-256(expectedRpId), it accepts credentials from any authenticator registered on any domain. In a phishing scenario, an attacker registers a credential on their phishing domain skillaudit-login.com and replays the registration credential response against the legitimate skillaudit.dev API — bypassing the credential binding entirely.

// VULNERABLE: rpIdHash in authenticatorData not verified
const crypto = require('crypto');
const { isoBase64URL, cbor } = require('@simplewebauthn/server/helpers');

app.post('/webauthn/auth/verify', async (req, res) => {
  const authDataBuffer = isoBase64URL.toBuffer(req.body.response.authenticatorData);

  // Parse authenticatorData manually
  // First 32 bytes: rpIdHash
  // Byte 32: flags
  // Bytes 33-36: sign counter
  const rpIdHash = authDataBuffer.slice(0, 32);
  const flags = authDataBuffer[32];
  const counter = authDataBuffer.readUInt32BE(33);

  // VULNERABLE: rpIdHash read from client-supplied authenticatorData but never compared
  // to SHA-256(expectedRpId) — accepts credentials from any domain

  const userPresent = !!(flags & 0x01);    // UP flag
  const userVerified = !!(flags & 0x04);   // UV flag

  if (!userPresent || !userVerified) {
    return res.status(400).json({ error: 'User not verified' });
  }

  // Proceeds to signature verification WITHOUT rpId binding check
  // An attacker can submit authenticatorData from a different domain
  // The signature is valid because it was signed with a legitimately registered credential
  // — just registered on the wrong domain
  res.json({ verified: true });
});
// FIXED: @simplewebauthn/server verifies rpIdHash automatically
// verifyAuthenticationResponse() checks rpIdHash === SHA-256(expectedRPID)
// No manual authenticatorData parsing required — the library handles it

const { verifyAuthenticationResponse } = require('@simplewebauthn/server');

app.post('/webauthn/auth/verify', async (req, res) => {
  // ...challenge retrieval and credential lookup (see WEBAUTHN-002)...

  let verification;
  try {
    verification = await verifyAuthenticationResponse({
      response: req.body,
      expectedChallenge: storedChallenge,
      expectedOrigin: 'https://skillaudit.dev',
      expectedRPID: 'skillaudit.dev',   // Library verifies rpIdHash === SHA-256('skillaudit.dev')
      credential: {
        id: credential.credentialID,
        publicKey: credential.credentialPublicKey,
        counter: credential.counter,
        transports: credential.transports,
      },
      requireUserVerification: true,
    });
  } catch (err) {
    // Throws on rpIdHash mismatch — credentials from other domains rejected
    return res.status(400).json({ error: 'Verification failed' });
  }

  // Manual implementation if not using @simplewebauthn/server:
  // const expectedRpIdHash = crypto.createHash('sha256').update('skillaudit.dev').digest();
  // const actualRpIdHash = authDataBuffer.slice(0, 32);
  // if (!crypto.timingSafeEqual(expectedRpIdHash, actualRpIdHash)) {
  //   return res.status(400).json({ error: 'rpId mismatch' });
  // }

  res.json({ verified: verification.verified });
});
HIGH
SA-SKL-WEBAUTHN-003 — MCP skill parses authenticatorData manually but does not compare the first 32 bytes (rpIdHash) against SHA-256(expectedRpId); a credential registered on a phishing or attacker-controlled domain can be submitted against the legitimate RP API and pass verification because the credential signature is structurally valid — only the rpId binding check would catch the mismatch. Fix: use @simplewebauthn/server verifyAuthenticationResponse() with expectedRPID set to the application's domain; the library performs rpIdHash verification automatically; for manual implementations, compare authData.slice(0,32) against crypto.createHash('sha256').update(expectedRpId).digest() using timingSafeEqual. Detection: SkillAudit flags WebAuthn handlers that read authenticatorData without a subsequent SHA-256 comparison against the expected rpId.

WEBAUTHN-004 — Sign counter not checked

Hardware authenticators maintain a monotonically increasing sign counter that increments on every authentication. The server stores the last-seen counter value and must reject any authentication where the new counter is not strictly greater than the stored value. This is the WebAuthn specification's mechanism for detecting credential cloning: if an authenticator's private key has been extracted and copied to another device, both copies will produce signatures, but their counters will diverge. When the legitimate user authenticates, the server sees counter N+1; when the attacker authenticates with the clone, the server sees a counter value at or below the stored value — a cloning signal. If the RP never checks the counter, credential cloning is completely undetected. The attacker's cloned credential produces valid signatures indefinitely without triggering any alarm.

// VULNERABLE: sign counter never checked or updated
app.post('/webauthn/auth/verify', async (req, res) => {
  const authDataBuffer = isoBase64URL.toBuffer(req.body.response.authenticatorData);
  const newCounter = authDataBuffer.readUInt32BE(33);

  // VULNERABLE: counter value read but never compared to stored value
  // Credential cloning is completely undetected — both original and clone pass verification

  const credential = await db.credentials.findOne({ credentialID: req.body.id });

  // Verifies signature... (omitted for brevity)

  // VULNERABLE: counter never updated in database
  // Even if counter were checked, it would always see counter=0 vs any newCounter
  // so the check would always pass for any cloned credential

  // Correct behavior: should reject if newCounter <= credential.counter
  // Should update credential.counter = newCounter after successful auth

  res.json({ verified: true });
});
// FIXED: sign counter checked and updated — clone detection active
const { verifyAuthenticationResponse } = require('@simplewebauthn/server');

app.post('/webauthn/auth/verify', async (req, res) => {
  const credential = await db.credentials.findOne({
    credentialID: req.body.id,
    userId: req.session.userId,
  });

  let verification;
  try {
    verification = await verifyAuthenticationResponse({
      response: req.body,
      expectedChallenge: storedChallenge,
      expectedOrigin: 'https://skillaudit.dev',
      expectedRPID: 'skillaudit.dev',
      credential: {
        id: credential.credentialID,
        publicKey: credential.credentialPublicKey,
        counter: credential.counter,  // Stored counter — library checks newCounter > this
        transports: credential.transports,
      },
      requireUserVerification: true,
    });
  } catch (err) {
    // verifyAuthenticationResponse throws if newCounter <= storedCounter
    // This indicates credential cloning — log and alert security team
    if (err.message?.includes('counter')) {
      await securityAlerts.create({
        type: 'CREDENTIAL_CLONE_SUSPECTED',
        credentialId: req.body.id,
        userId: credential.userId,
        storedCounter: credential.counter,
        // Do not log newCounter from req.body — attacker-controlled
        timestamp: new Date(),
      });
      // Invalidate all credentials for this user — potential full compromise
      await db.credentials.revokeAll({ userId: credential.userId });
    }
    return res.status(400).json({ error: 'Verification failed' });
  }

  if (!verification.verified) {
    return res.status(400).json({ error: 'Not verified' });
  }

  // FIXED: update stored counter to new value after successful authentication
  await db.credentials.update(credential.id, {
    counter: verification.authenticationInfo.newCounter,
    lastUsedAt: new Date(),
  });

  // Note: software authenticators (platform authenticators on some devices)
  // may always return counter=0. The spec allows this — only flag if
  // storedCounter > 0 AND newCounter <= storedCounter.
  // @simplewebauthn/server handles this edge case automatically.

  req.session.authenticated = true;
  await req.session.save();
  res.json({ verified: true });
});
MEDIUM
SA-SKL-WEBAUTHN-004 — MCP skill WebAuthn authentication handler does not check the sign counter in authenticatorData against the stored counter value; the sign counter is the WebAuthn specification's primary defense against credential cloning — if an attacker extracts a hardware authenticator's private key, both the original and the clone produce valid signatures, but the counter values diverge; without counter checking, the clone is accepted indefinitely without triggering any detection. Fix: store the credential's counter after each successful authentication; pass the stored counter to verifyAuthenticationResponse() as credential.counter — the library rejects if newCounter <= storedCounter; on counter mismatch, revoke all credentials for the user and generate a security alert. Detection: SkillAudit flags WebAuthn authentication handlers that do not update a stored counter after successful authentication.

SkillAudit detection summary — SA-SKL-WEBAUTHN

Pattern IDSeverityWhat SkillAudit flagsFix
WEBAUTHN-001HIGHRegistration handlers that decode attestationObject without calling an attestation-verification functionverifyRegistrationResponse() from @simplewebauthn/server with expectedChallenge, expectedOrigin, expectedRPID
WEBAUTHN-002CRITICALAuthentication flows where challenge is returned to client but no session write is observed; flows that read challenge from req.bodyStore challenge in server-side session; clear before verify (single-use); pass as expectedChallenge
WEBAUTHN-003HIGHManual authenticatorData parsing without SHA-256 comparison of first 32 bytes against expected rpIdverifyAuthenticationResponse() with expectedRPID; or manual timingSafeEqual against SHA-256(rpId)
WEBAUTHN-004MEDIUMAuthentication handlers that do not write an updated counter to the credential record after successful authenticationPass stored counter to verifyAuthenticationResponse(); update after success; revoke all creds on mismatch

Related patterns: For OAuth 2.0 state parameter and PKCE vulnerabilities that affect authentication flows in a similar way, see SA-SKL-OAUTH. For session management after WebAuthn authentication, see SA-SKL-SESSIONFIX. For timing-safe comparison requirements in cryptographic verification, see SA-SKL-TIMING.