← Blog

WebAuthn Passkey Security in Claude MCP Skills: Attestation, Challenge Binding, and Credential Cloning Detection

WebAuthn and FIDO2 passkey authentication is increasingly common in Claude MCP skills that offer passwordless login. The W3C specification is rigorous — but implementations in Node.js MCP servers routinely skip the most security-critical verification steps because the browser-side API looks deceptively simple. SkillAudit audits find four consistent failure modes in passkey-enabled skills: attestation verification is skipped because it appears optional, the server-side challenge is never stored so any replay of a captured response passes, the rpId in authenticatorData is accepted from any domain enabling phishing-credential reuse, and the sign counter is never checked so credential cloning via hardware key extraction goes entirely undetected. SA-SKL-WEBAUTHN-001 through WEBAUTHN-004 cover each with the W3C spec section behind it, the vulnerable code pattern, the attack mechanics, and a drop-in fix using @simplewebauthn/server.

By SkillAudit  |  5 Nov 2026  |  14 min read

Why WebAuthn is harder to implement correctly than OAuth

OAuth 2.0 is a delegation protocol — its security model is primarily about token issuance and channel binding. WebAuthn is a public-key cryptography protocol — its security model requires the server to verify a cryptographic signature chain that spans the browser, the authenticator hardware, and the FIDO Metadata Service root. The OAuth implementation surface for a Node.js developer is roughly: validate state parameter, exchange code for token, store token safely. The WebAuthn verification surface is: parse a CBOR-encoded attestation object, verify an attestation signature chain against manufacturer certificates, validate the rpIdHash in authenticatorData, check the challenge in clientDataJSON, verify the credential signature over the authenticatorData + clientDataHash, and track the sign counter across sessions.

MCP skill developers adopting passkeys commonly reach for @simplewebauthn/server, which handles the full verification surface if used correctly. The vulnerabilities that SkillAudit finds most often are not incorrect use of the library — they are skipped calls to the library. The developer calls navigator.credentials.create() on the client, receives the credential response, and stores it directly without calling verifyRegistrationResponse(). Or calls verifyAuthenticationResponse() but forgets to store the challenge in the session before returning the options to the client. These errors are not visible in the happy path — a legitimate authenticator with a valid credential will pass even a broken verification. The attack surfaces only when an adversary actively exploits the absent check.

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). All four are detectable by static analysis of the WebAuthn handler code. All four are fixed by using @simplewebauthn/server verifyRegistrationResponse() and verifyAuthenticationResponse() with correct parameters.

Pattern 1 — WEBAUTHN-001

Attestation verification skipped

When a user registers a WebAuthn credential, the browser's navigator.credentials.create() call returns an AuthenticatorAttestationResponse that contains an attestationObject. This object is a CBOR-encoded structure containing three fields: fmt (the attestation format), authData (the authenticator data including the new credential's public key), and attStmt (the attestation statement — a signature from the authenticator device). The purpose of attestation is to allow the relying party to verify that the credential was created on a specific type of hardware authenticator, and that the hardware's attestation certificate chains up to a known FIDO MDS root.

The W3C WebAuthn spec §7.1 step 20 marks attestation verification as optional for fmt: "none" — credentials that carry no attestation. This is correct and intentional for consumer use cases where the type of authenticator does not matter. The vulnerability occurs when developers treat attestation as optional for all formats, including packed, fido-u2f, tpm, and android-key — formats that carry a verifiable signature. When the RP stores credentials without calling any attestation verification function, an attacker can register a credential with arbitrary attestation metadata, claiming it was issued by a hardware security key when it was generated by software under the attacker's control. For MCP skills that gate access on hardware-key-backed credentials (e.g., requiring a hardware token for admin operations), this completely defeats the access control.

// VULNERABLE: attestationObject stored without attestation verification
const { isoBase64URL, cbor } = require('@simplewebauthn/server/helpers');

app.post('/webauthn/register/verify', async (req, res) => {
  const attestationBuffer = isoBase64URL.toBuffer(
    req.body.response.attestationObject
  );
  const decoded = cbor.decode(attestationBuffer);

  // decoded.fmt: 'packed' | 'fido-u2f' | 'tpm' | 'none' | ...
  // decoded.attStmt: attestation signature — NEVER VERIFIED below

  // Directly extracts public key from authData without checking attStmt signature
  // An attacker submits fmt='packed' with a fabricated attStmt signed by a
  // self-signed certificate — the RP stores it without catching the forgery
  await db.credentials.create({
    userId: req.session.userId,
    credentialId: req.body.id,
    publicKey: decoded.authData.slice(55), // raw COSE key — no attestation check
    counter: 0,
  });
  res.json({ verified: true }); // Always true; no actual verification performed
});
// FIXED: verifyRegistrationResponse() performs full attestation signature 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', // 'direct' requests verifiable attestation
    authenticatorSelection: {
      residentKey: 'required',
      userVerification: 'required',
    },
  });
  req.session.webauthnChallenge = options.challenge; // Server-side (WEBAUTHN-002)
  await req.session.save();
  res.json(options);
});

app.post('/webauthn/register/verify', async (req, res) => {
  const expectedChallenge = req.session.webauthnChallenge;
  req.session.webauthnChallenge = null; // Single-use
  await req.session.save();

  let verification;
  try {
    verification = await verifyRegistrationResponse({
      response: req.body,
      expectedChallenge,                        // Server-side challenge
      expectedOrigin: 'https://skillaudit.dev', // Must match window.location.origin
      expectedRPID: 'skillaudit.dev',           // rpIdHash check (WEBAUTHN-003)
      // For high-assurance: pass expectedAttestationTypes: ['packed', 'fido-u2f']
      // to reject 'none' format credentials in privileged flows
    });
  } catch (err) {
    return res.status(400).json({ error: 'Registration failed' });
  }

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

  const { registrationInfo } = verification;
  await db.credentials.create({
    userId: req.session.userId,
    credentialID: registrationInfo.credential.id,
    credentialPublicKey: registrationInfo.credential.publicKey, // Verified COSE key
    counter: registrationInfo.credential.counter,               // Initial sign counter
    transports: registrationInfo.credential.transports,
    aaguid: registrationInfo.aaguid,         // Authenticator model GUID
    attestationFmt: registrationInfo.fmt,    // Stored for audit
  });
  res.json({ verified: true });
});

HIGH SA-SKL-WEBAUTHN-001 — MCP skill WebAuthn registration handler stores credentials without calling a library that verifies the attestation statement signature against the authenticator's attestation certificate chain and the FIDO Metadata Service; raw CBOR decoding of attestationObject without signature verification allows an attacker to register fabricated credentials that claim hardware-key provenance. Fix: use @simplewebauthn/server verifyRegistrationResponse() with expectedChallenge, expectedOrigin, expectedRPID.

Pattern 2 — WEBAUTHN-002

Server-side challenge not stored

The WebAuthn challenge is the replay-attack defense. The server generates a cryptographically random 32-byte value, includes it in the registration or authentication options, and later verifies that the challenge field in the returned clientDataJSON matches the one it generated. The check is only meaningful if the challenge was stored on the server — if the server accepts a challenge from the POST body, or never stored the challenge and reconstructs it from client data, an adversary can replay any previously captured valid authentication response. The stolen response is structurally complete: it contains a valid signature from a registered credential. The only protection against replay is the server-side challenge that proves this response was generated in response to this specific authentication request.

The most common broken pattern is a GET handler that generates a challenge and returns it in the response body without writing it to the session. The server immediately forgets the challenge. The POST handler receives the credential response, parses clientDataJSON to extract the challenge, and compares it against… the challenge it just extracted from the client-supplied POST body. The comparison always passes because both sides of the comparison come from the same client-supplied data.

// VULNERABLE: challenge generated but never stored server-side
app.get('/webauthn/auth/options', async (req, res) => {
  const challenge = crypto.randomBytes(32).toString('base64url');
  // Challenge returned to client — but server stores nothing
  res.json({ challenge, rpId: 'skillaudit.dev', userVerification: 'required' });
});

app.post('/webauthn/auth/verify', async (req, res) => {
  const clientData = JSON.parse(
    Buffer.from(req.body.response.clientDataJSON, 'base64').toString()
  );

  // VULNERABLE: expectedChallenge comes from the client's POST body, not from server storage
  // An attacker replays a captured authentication response with its original challenge
  // Both sides of the comparison are attacker-controlled
  const expectedChallenge = clientData.challenge;

  const verification = await verifyAuthenticationResponse({
    response: req.body,
    expectedChallenge, // ← points to client-supplied value: always matches itself
    expectedOrigin: 'https://skillaudit.dev',
    expectedRPID: 'skillaudit.dev',
    credential: { /* ... */ },
  });
  // verification.verified is true for any valid-but-replayed response
  res.json({ verified: verification.verified });
});
// FIXED: challenge stored in server-side session before returning options
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: challenge written to server-side session with TTL matching timeout
  req.session.webauthnChallenge = options.challenge;
  req.session.webauthnChallengeExpiry = Date.now() + 65000;
  await req.session.save(); // Must persist before response is sent

  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,
        transports: credential.transports,
      },
      requireUserVerification: true,
    });
  } catch (err) {
    return res.status(400).json({ error: 'Verification failed' });
  }

  await db.credentials.update(credential.id, {
    counter: verification.authenticationInfo.newCounter,
  });
  req.session.authenticated = true;
  await req.session.save();
  res.json({ verified: verification.verified });
});

CRITICAL SA-SKL-WEBAUTHN-002 — MCP skill WebAuthn GET options handler generates a challenge but does not write it to server-side session storage; the POST verify handler uses the challenge extracted from client-supplied clientDataJSON as expectedChallenge, making the comparison trivially passable by any replayed authentication response. Fix: write challenge to req.session.webauthnChallenge before sending the response; clear it before verification (single-use); pass storedChallenge as expectedChallenge.

Pattern 3 — WEBAUTHN-003

rpId not validated in authenticatorData

The rpIdHash occupies the first 32 bytes of every WebAuthn authenticatorData blob. It is a SHA-256 hash of the relying party identifier (the rpId, typically the application's registrable domain — skillaudit.dev). Its purpose is to cryptographically bind a credential to a specific origin: a credential registered on evil-login.com cannot be replayed on skillaudit.dev because SHA-256('evil-login.com') ≠ SHA-256('skillaudit.dev'). The WebAuthn spec §7.2 step 11 requires the RP to verify that rpIdHash === SHA-256(expectedRpId) before accepting the authentication.

When developers parse authenticatorData manually — to extract the counter, flags, or attested credential data — they often read the first 32 bytes without comparing them to anything. The credential signature still verifies because the signature covers the full authenticatorData including the rpIdHash. The signature is structurally valid; the rpId binding check is simply absent. In a phishing attack, an adversary registers a credential on their domain skillaudit-login.com. The user's browser creates a valid credential there. The attacker captures the authentication response (via the phishing form) and replays it against skillaudit.dev/webauthn/auth/verify. Without the rpId check, the RP verifies the credential signature (which is valid — the credential was legitimately created by the user) and grants an authenticated session.

// VULNERABLE: authenticatorData parsed manually without rpIdHash verification
app.post('/webauthn/auth/verify', async (req, res) => {
  const authData = Buffer.from(req.body.response.authenticatorData, 'base64url');

  const rpIdHashFromClient = authData.slice(0, 32); // First 32 bytes
  const flags = authData[32];
  const counter = authData.readUInt32BE(33);

  // VULNERABLE: rpIdHashFromClient is read but never compared to SHA-256(expectedRpId)
  // A credential registered on a phishing domain passes this handler
  // because the signature covers the full authData — it's structurally valid

  const userPresent = !!(flags & 0x01);
  const userVerified = !!(flags & 0x04);
  if (!userPresent || !userVerified) {
    return res.status(400).json({ error: 'User not verified' });
  }

  // Verifies the credential signature (structurally valid for a phishing credential)
  // but never checks which domain the credential is bound to
  res.json({ verified: true });
});
// FIXED: rpIdHash verified automatically by verifyAuthenticationResponse()
// If using @simplewebauthn/server, expectedRPID does the check
// Manual implementation shown as reference:

const crypto = require('crypto');

function verifyRpIdHash(authDataBuffer, expectedRpId) {
  const rpIdHashFromAuthData = authDataBuffer.slice(0, 32);
  const expectedRpIdHash = crypto.createHash('sha256').update(expectedRpId).digest();
  // timingSafeEqual prevents timing-oracle on the hash comparison
  if (!crypto.timingSafeEqual(rpIdHashFromAuthData, expectedRpIdHash)) {
    throw new Error('rpIdHash mismatch — credential bound to different domain');
  }
}

// Using @simplewebauthn/server (recommended — handles this automatically):
const { verifyAuthenticationResponse } = require('@simplewebauthn/server');

const verification = await verifyAuthenticationResponse({
  response: req.body,
  expectedChallenge: storedChallenge,
  expectedOrigin: 'https://skillaudit.dev',
  expectedRPID: 'skillaudit.dev', // ← Library computes SHA-256('skillaudit.dev')
                                   //   and compares against authData[0:32]
  credential: {
    id: credential.credentialID,
    publicKey: credential.credentialPublicKey,
    counter: credential.counter,
    transports: credential.transports,
  },
  requireUserVerification: true,
});
// Throws if rpIdHash does not match — phishing credentials rejected

HIGH SA-SKL-WEBAUTHN-003 — MCP skill WebAuthn authentication handler parses authenticatorData manually but does not compare the first 32 bytes (rpIdHash) against SHA-256(expectedRpId); a credential registered on a phishing domain can be replayed against the legitimate RP because the credential signature remains structurally valid — only the rpId binding check would catch the cross-origin mismatch. Fix: use @simplewebauthn/server verifyAuthenticationResponse() with expectedRPID; for manual implementations, crypto.timingSafeEqual(authData.slice(0,32), SHA-256(expectedRpId)).

Pattern 4 — WEBAUTHN-004

Sign counter not checked — credential cloning undetected

Hardware authenticators maintain a monotonically increasing sign counter, stored in the device's secure element, that increments on every authentication ceremony. The relying party stores the last-seen counter value and must reject any authentication where the returned counter is not strictly greater than the stored value (spec §7.2 step 17). This is the WebAuthn specification's primary defense against credential cloning: if an attacker extracts the private key from a hardware authenticator (via side-channel, supply chain attack, or physical access) and copies it to another device, both the original and the clone will produce valid signatures. When the legitimate user authenticates, the server records counter N. When the attacker authenticates with the clone, the server sees counter M — where M may be less than, equal to, or only slightly greater than N depending on which device has been used more recently. Without counter tracking, the clone is completely undetectable: both devices produce valid signatures indefinitely.

The broken pattern is subtle: the counter is often read from authenticatorData (it's bytes 33–36) but never compared against a stored value. The developer may log the counter or return it in the response, giving the appearance of counter tracking, while never actually enforcing the monotonic increment rule.

// VULNERABLE: sign counter read but never enforced
app.post('/webauthn/auth/verify', async (req, res) => {
  const authData = Buffer.from(req.body.response.authenticatorData, 'base64url');
  const newCounter = authData.readUInt32BE(33);

  // Counter is logged — appears active — but stored value is never read or compared
  console.log(`Auth counter: ${newCounter}`);

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

  // Verifies the cryptographic signature (valid for both original and clone)
  const signatureValid = await verifySignature(
    credential.credentialPublicKey,
    req.body.response.authenticatorData,
    req.body.response.clientDataHash
  );

  if (!signatureValid) return res.status(400).json({ error: 'Invalid signature' });

  // VULNERABLE: credential.counter never updated — clone detection impossible
  // Even if a check were added later, it would compare against stale counter=0
  res.json({ verified: true });
});
// FIXED: sign counter enforced — cloning triggers security alert and revocation
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,
  });
  if (!credential) return res.status(400).json({ error: 'Unknown credential' });

  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, // ← Library checks: newCounter > this value
        transports: credential.transports,
      },
      requireUserVerification: true,
    });
  } catch (err) {
    if (err.message?.includes('counter')) {
      // Counter did not advance — probable credential clone
      await securityAlerts.create({
        type: 'CREDENTIAL_CLONE_SUSPECTED',
        credentialId: req.body.id,
        userId: credential.userId,
        storedCounter: credential.counter,
        at: new Date(),
      });
      // Revoke ALL credentials for this user — entire account may be compromised
      await db.credentials.revokeAll({ userId: credential.userId });
      await notifyUser(credential.userId, 'suspicious_webauthn_activity');
    }
    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 — next auth must exceed this
  await db.credentials.update(credential.id, {
    counter: verification.authenticationInfo.newCounter,
    lastUsedAt: new Date(),
  });

  // Edge case: software authenticators and some platform authenticators always
  // return counter=0. The spec permits this. @simplewebauthn/server handles it —
  // it only throws if storedCounter > 0 AND newCounter <= storedCounter.

  req.session.authenticated = true;
  await req.session.save();
  res.json({ verified: true });
});

MEDIUM SA-SKL-WEBAUTHN-004 — MCP skill WebAuthn authentication handler does not compare the sign counter in authenticatorData (bytes 33–36) against the stored credential counter value; without counter enforcement, hardware authenticator cloning via private key extraction is completely undetected as both original and clone produce valid signatures indefinitely. Fix: pass credential.counter (stored value) to verifyAuthenticationResponse(); the library rejects if newCounter <= storedCounter (excluding platform authenticators that always return 0); update the stored counter after every successful authentication; on mismatch, revoke all user credentials and generate a security alert.

Implementation checklist

WebAuthn implementation checklist using @simplewebauthn/server

These four checks are the most commonly missing in MCP skill audits. Using @simplewebauthn/server correctly covers all four — the gaps arise when the library calls are skipped or when parameters are omitted:

CheckSpec §Severity if skippedHow @simplewebauthn/server covers it
Attestation verification§7.1 step 19–20HIGHverifyRegistrationResponse() verifies attStmt signature chain against FIDO MDS when attestationType: 'direct'
Server-side challenge§7.2 step 11CRITICALverifyAuthenticationResponse({ expectedChallenge }) — must pass server-stored value, not client-extracted value
rpIdHash binding§7.2 step 13HIGHverifyAuthenticationResponse({ expectedRPID }) computes SHA-256(rpId) and compares against authData[0:32]
Sign counter enforcement§7.2 step 17MEDIUMverifyAuthenticationResponse({ credential: { counter } }) throws if newCounter <= storedCounter (excluding zero-counter platform authenticators)

Related patterns: For OAuth 2.0 state parameter and PKCE vulnerabilities that affect authentication flows in a similar way, see SA-SKL-OAUTH. For JWT algorithm confusion attacks that affect token-based authentication in MCP skills, see SA-SKL-JWTALG. For timing-safe comparison requirements across cryptographic verification functions, see SA-SKL-TIMING.

What SkillAudit scans for

SkillAudit's static analysis rules for SA-SKL-WEBAUTHN look for four patterns in MCP skill source trees: (1) WebAuthn registration handlers that call cbor.decode(attestationObject) or isoBase64URL.toBuffer() on the attestation object without a subsequent call to verifyRegistrationResponse(); (2) WebAuthn GET options handlers that generate a challenge with crypto.randomBytes or generateAuthenticationOptions() without a req.session write before the response is sent; (3) WebAuthn POST verify handlers that read clientDataJSON and extract the challenge from it before calling verifyAuthenticationResponse(); (4) WebAuthn verify handlers that call a database update on a credential record but do not include a counter field in the update. Each rule produces a finding with the specific line reference, the attack scenario, and the fix. All four rules can be detected without executing the code — pure static analysis over the AST using tree-sitter.

Run a free audit of your MCP skill at skillaudit.dev to see which of these patterns appear in your implementation. The SA-SKL-WEBAUTHN report includes code-level findings with line references and copy-pasteable fixes.