← Blog

Claude skill timing side-channel attacks via response-time differences in MCP skills — SA-SKL-TIMING3

Timing side-channels are a category of vulnerability where the time an operation takes reveals information the attacker should not have. SA-SKL-TIMING3 covers four patterns found in Claude MCP skill implementations: a non-constant-time HMAC token comparison that leaks secret bytes one character at a time via measurable response latency differences; a bcrypt.compare short-circuit that returns faster for non-existent users than for wrong-password users, enabling username enumeration from a remote endpoint; an audit report latency difference that reveals whether a GitHub repository exists but is private versus truly non-existent; and a SQL query execution time variance that leaks whether a row exists in the database independent of the application-layer response code. Each of these is exploitable over a network given sufficient request volume and statistical analysis.

By SkillAudit  |  8 Nov 2026

Timing attacks in MCP skill authentication and data-access paths

A timing attack requires that the attacker can measure the response time of a target operation and that the response time varies in a way that is correlated with a secret value. Modern CPU branch prediction, OS scheduling jitter, and network latency all add noise, but with enough samples the signal can be recovered statistically. In an MCP skill context, two operations are particularly attractive targets: authentication checks (token comparison, password verification) and resource-existence checks (does repo X exist? does user Y exist?). Both appear in every skill that authenticates callers or proxies access to private resources, and both are commonly implemented with naive equality comparisons that leak timing information. The fix in both cases is constant-time comparison — an operation whose runtime is independent of the secret value.

SA-SKL-TIMING3 findings at a glance
HIGHTIMING3-001 — token === expected HMAC comparison returns early on first byte mismatch; attacker measures response time variance to brute-force token one byte at a time
HIGHTIMING3-002 — bcrypt.compare not called for non-existent users; login faster for unknown usernames than wrong passwords; attacker enumerates valid usernames by response time
MEDIUMTIMING3-003 — audit report latency differs between private (exists, access denied) and non-existent repos; attacker probes repo existence via timing oracle
MEDIUMTIMING3-004 — SQL query execution time differs between record-exists and record-missing paths; application returns identical 404 but timing leaks existence

TIMING3-001 — Non-constant-time HMAC token comparison leaks token bytes

When an MCP skill verifies an API key or webhook signature using the JavaScript === operator, the comparison short-circuits at the first byte where the strings differ. If the token is abc123 and the attacker guesses aXXXXX versus bXXXXX, the comparison with aXXXXX takes slightly longer (passes the first byte check before failing on the second) than with bXXXXX (fails immediately on the first byte). With enough samples per candidate value, this nanosecond difference becomes statistically detectable even over a local network, allowing an attacker to brute-force the token one character at a time — reducing a 62^N search space to 62*N comparisons. The correct fix is crypto.timingSafeEqual, which compares two equal-length Buffer objects in constant time regardless of their contents. The comparison must also be preceded by a length check that does not short-circuit on length — always hash both token and expected to equal-length digests before passing to timingSafeEqual.

// VULNERABLE — === short-circuits on first byte mismatch; timing leaks token bytes
import crypto from 'crypto';

function verifyWebhookSignature(payload, receivedSignature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');

  // VULNERABLE: === returns early on first character mismatch
  // With 10k samples per byte position, 1-2ms difference is detectable
  if (receivedSignature !== expected) {
    return false;
  }
  return true;
}

app.post('/webhook', (req, res) => {
  const sig = req.headers['x-skillaudit-signature'] ?? '';
  if (!verifyWebhookSignature(req.rawBody, sig, process.env.WEBHOOK_SECRET)) {
    return res.status(401).json({ error: 'Invalid signature' });
  }
  processWebhook(req.body);
  res.sendStatus(200);
});
// FIXED — crypto.timingSafeEqual on equal-length HMAC digests; constant time
import crypto from 'crypto';

function verifyWebhookSignature(payload, receivedSignature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest(); // Buffer

  // Normalize received to Buffer of same length before comparison
  // If receivedSignature length != expected.length, timingSafeEqual would throw
  // — hash received value to same 32-byte length first
  let received;
  try {
    // If sig is hex-encoded: decode to Buffer
    received = Buffer.from(receivedSignature, 'hex');
  } catch {
    return false;
  }

  if (received.length !== expected.length) {
    // Length check itself must not leak timing — use timingSafeEqual on
    // a dummy buffer of the right length to consume constant time
    return crypto.timingSafeEqual(expected, expected) && false;
  }

  // FIXED: timingSafeEqual runs in O(n) time regardless of byte values
  return crypto.timingSafeEqual(expected, received);
}

app.post('/webhook', (req, res) => {
  const sig = req.headers['x-skillaudit-signature'] ?? '';
  if (!verifyWebhookSignature(req.rawBody, sig, process.env.WEBHOOK_SECRET)) {
    return res.status(401).json({ error: 'Invalid signature' });
  }
  processWebhook(req.body);
  res.sendStatus(200);
});

TIMING3-002 — bcrypt short-circuit on non-existent user enables username enumeration

Password hashing with bcrypt is intentionally slow — typically 100–300 ms per comparison on a modern server. When a login endpoint looks up a user by email and only calls bcrypt.compare if the user exists, the response time for a non-existent email is determined by the database lookup (a few milliseconds) while the response time for a valid email with a wrong password includes the full bcrypt work factor (100–300 ms). An attacker measuring response times across a list of candidate email addresses can identify which addresses have accounts with 100% accuracy using a threshold of roughly 50 ms. This information is used for targeted phishing, credential stuffing, and social engineering. The fix is to always call bcrypt.compare regardless of whether the user was found — compare the supplied password against a pre-computed dummy hash stored as a constant in the application so the work factor is always paid.

// VULNERABLE — bcrypt.compare skipped for non-existent users; login faster for unknown emails
import bcrypt from 'bcrypt';
import { db } from './db.js';

app.post('/login', async (req, res) => {
  const { email, password } = req.body;
  const user = await db.users.findOne({ email });

  // VULNERABLE: early return for non-existent user skips bcrypt work factor
  // Response time: ~5ms (DB only) for unknown email vs ~200ms (DB + bcrypt) for wrong password
  if (!user) {
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  const valid = await bcrypt.compare(password, user.passwordHash);
  if (!valid) {
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  const token = generateSessionToken(user.id);
  res.json({ token });
});
// FIXED — always call bcrypt.compare, including against dummy hash for non-existent users
import bcrypt from 'bcrypt';
import { db } from './db.js';

// Pre-computed dummy hash — pay the work factor even when user not found
// Generate once: bcrypt.hashSync('dummy-constant-value', 12)
const DUMMY_HASH = '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewdBPj/XkFkO3RnS';

app.post('/login', async (req, res) => {
  const { email, password } = req.body;
  const user = await db.users.findOne({ email });

  // FIXED: always call bcrypt.compare — pay work factor regardless of user existence
  // If user not found, compare against dummy hash; result will be false
  const hashToCompare = user?.passwordHash ?? DUMMY_HASH;
  const valid = await bcrypt.compare(password, hashToCompare);

  // Identical response body and status for both "user not found" and "wrong password"
  if (!user || !valid) {
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  const token = generateSessionToken(user.id);
  res.json({ token });
});

TIMING3-003 — Audit report latency leaks private GitHub repository existence

When an MCP skill submits a GitHub URL for auditing, the audit engine calls the GitHub API to fetch the repository metadata. GitHub returns HTTP 404 for both a private repository (the caller lacks access) and a truly non-existent repository, but the response time differs: a private repository triggers an authorization check that takes a few extra milliseconds compared to a repository that simply does not exist in the database. An attacker who can submit audit requests can measure the response time of the audit endpoint across a list of candidate repository names to determine which repositories exist privately. This reveals confidential project names, unreleased products, or internal tooling that the owner believed was hidden. The fix is to normalize the response time for all 404-class outcomes to a fixed latency by sleeping until a minimum deadline before responding.

// VULNERABLE — audit latency leaks private repo existence; GitHub API timing differs
import { Octokit } from '@octokit/rest';

const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });

app.post('/api/audit', authenticate, async (req, res) => {
  const { repoUrl } = req.body;
  const { owner, repo } = parseGitHubUrl(repoUrl);

  let repoData;
  try {
    const { data } = await octokit.repos.get({ owner, repo });
    repoData = data;
  } catch (err) {
    if (err.status === 404) {
      // VULNERABLE: returns immediately — private repo 404 ~12ms, non-existent ~4ms
      // Attacker measures response time to determine if repo exists privately
      return res.status(404).json({ error: 'Repository not found or inaccessible' });
    }
    throw err;
  }

  const report = await runAudit(repoData);
  res.json(report);
});
// FIXED — pad 404 responses to fixed minimum latency to eliminate timing oracle
import { Octokit } from '@octokit/rest';

const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });

// Minimum response time for all repo-fetch paths regardless of outcome
const MIN_RESPONSE_MS = 150;

app.post('/api/audit', authenticate, async (req, res) => {
  const { repoUrl } = req.body;
  const { owner, repo } = parseGitHubUrl(repoUrl);
  const startMs = Date.now();

  let repoData;
  let notFound = false;
  try {
    const { data } = await octokit.repos.get({ owner, repo });
    repoData = data;
  } catch (err) {
    if (err.status === 404) {
      notFound = true;
    } else {
      throw err;
    }
  }

  if (notFound) {
    // FIXED: sleep until MIN_RESPONSE_MS has elapsed regardless of which 404 path triggered
    const elapsed = Date.now() - startMs;
    if (elapsed < MIN_RESPONSE_MS) {
      await new Promise(r => setTimeout(r, MIN_RESPONSE_MS - elapsed));
    }
    // Identical response for private-repo-exists-but-forbidden vs truly-non-existent
    return res.status(404).json({ error: 'Repository not found or inaccessible' });
  }

  const report = await runAudit(repoData);
  res.json(report);
});

TIMING3-004 — SQL execution time leaks DB record existence via index timing

Even with parameterized queries that prevent SQL injection, the execution time of a query can differ between a row that exists and a row that does not exist. On a table with a B-tree index on the lookup column, a query for a non-existent key misses the index leaf page (the lookup terminates early) while a query for an existing key traverses to the leaf and reads the row — a measurable difference in CPU and I/O time under some database configurations. The application may return an identical HTTP 404 body for both cases, but the response time variance allows an attacker to build an existence oracle. This is particularly impactful for endpoints that look up audit tokens, API keys, or invite codes where guessing valid values has direct security consequences. The fix is application-level timing normalization: record the start time before the query, then sleep until a fixed deadline after the query before sending the response, equalizing the response time for hit and miss paths.

// VULNERABLE — parameterized query but response time leaks record existence
import { pool } from './db.js';

app.get('/api/invite/:code', async (req, res) => {
  const { code } = req.params;

  // VULNERABLE: query time differs between existing code (~2ms with index hit)
  // and non-existent code (~0.5ms with index miss) — attacker measures 10k requests
  // to map which 8-char codes are valid invite codes
  const result = await pool.query(
    'SELECT id, used_at, plan FROM invite_codes WHERE code = $1',
    [code]
  );

  if (result.rows.length === 0) {
    return res.status(404).json({ error: 'Invalid invite code' });
  }

  const invite = result.rows[0];
  if (invite.used_at) {
    return res.status(410).json({ error: 'Invite code already used' });
  }

  res.json({ valid: true, plan: invite.plan });
});
// FIXED — fixed minimum latency normalizes response time across hit/miss paths
import { pool } from './db.js';

const INVITE_LOOKUP_MIN_MS = 50;

app.get('/api/invite/:code', async (req, res) => {
  const { code } = req.params;
  const startMs = Date.now();

  // FIXED: query executes normally (still parameterized to prevent injection)
  const result = await pool.query(
    'SELECT id, used_at, plan FROM invite_codes WHERE code = $1',
    [code]
  );

  // Normalize response time: sleep until INVITE_LOOKUP_MIN_MS has elapsed
  // Both hit and miss paths wait the same total time before responding
  const elapsed = Date.now() - startMs;
  if (elapsed < INVITE_LOOKUP_MIN_MS) {
    await new Promise(r => setTimeout(r, INVITE_LOOKUP_MIN_MS - elapsed));
  }

  if (result.rows.length === 0) {
    return res.status(404).json({ error: 'Invalid invite code' });
  }

  const invite = result.rows[0];
  if (invite.used_at) {
    return res.status(410).json({ error: 'Invite code already used' });
  }

  res.json({ valid: true, plan: invite.plan });
});

Related patterns: For other authentication bypass patterns in MCP skills beyond timing, see SA-SKL-JWT5 which covers JWT algorithm confusion and key injection. Username enumeration via different error messages (not just timing) is covered alongside injection patterns in SA-SKL-INJECTION6. For rate limiting that interacts with authentication endpoints, see SA-SKL-RATELIMIT7.

FindingSeverityVulnerable patternFix
TIMING3-001HighHMAC token compared with ===; short-circuits on first byte mismatch; response time variance enables byte-by-byte brute-forcecrypto.timingSafeEqual(Buffer, Buffer) on equal-length HMAC digests; never compare secrets with ===
TIMING3-002Highbcrypt.compare skipped for non-existent users; response 5ms vs 200ms leaks which emails have accountsAlways call bcrypt.compare against a pre-computed dummy hash when user not found; identical response body for both cases
TIMING3-003MediumGitHub API 404 for private repos takes ~12ms; truly non-existent repos ~4ms; audit endpoint latency reveals repo existenceSleep until fixed minimum deadline (150ms+) before responding to any 404-class outcome; normalize across all error paths
TIMING3-004MediumSQL index-miss faster than index-hit; identical 404 body but response time leaks invite code existenceRecord start time; sleep until fixed minimum delay after query; equalize response latency for all query outcomes