Skip to content

VNX-804: Guessable CAPTCHA

Reports home-grown CAPTCHA code in JavaScript/TypeScript and Python that an automated client can solve without solving the challenge.

Updated 05 Nov 2026Markdown
Field Value
Rule ID VNX-804
Severity Medium
SARIF level warning
Kind sast
Languages JavaScript / TypeScript, Python
CWE CWE-804
CAPEC CAPEC-66
ATT&CK T1190
CWSS vector CWSS:1.0/TI:M/AP:RU/AL:S/IC:N/FC:LT/RP:RU/RL:S/AV:L/AS:N/IN:A/SC:A/BI:M/DI:H/EX:M/EC:N/P:C
Tags captcha-bypass cwe-804
Source internal/sast/rules/vnx-804.rego

Overview

VNX-804 maps to CWE-804: Guessable CAPTCHA. It reports three ways a home-grown CAPTCHA stops a human but not a bot: a predictable generator, an answer sent to the client, and a verification that passes when the stored challenge is missing.

What gets flagged

// FLAGGED: predictable challenge
const captchaCode = Math.random().toString(36).slice(2, 8);

// FLAGGED: the object sent holds the answer
const captcha = { captchaId: nextId(), captcha: expression, answer };
res.json(captcha);

// FLAGGED: an unknown captcha id passes
if (!captchas[0] || req.body.answer === captchas[0].answer) { return next(); }
# FLAGGED: the solution is returned with the question
return jsonify({"question": question, "solution": solution})

# FLAGGED: random.randint in captcha code
code = random.randint(1000, 9999)

Not flagged: crypto.randomInt(...), secrets.choice(...), random.SystemRandom(), a response that sends only the id and the image, reCAPTCHA verification.

// FLAGGED: rejects only when the stored CAPTCHA exists, so an unknown id passes
if (captcha && captcha.answer !== String(req.body.captcha)) {
  return res.status(401).json({ error: 'Wrong answer' });
}

// FLAGGED: shorthand answer key in the response
res.json({ captchaId, question: `${a} + ${b} = ?`, answer });

Not flagged: the fail-closed if (!entry || entry.answer !== given) return res.status(400), and res.send(captcha.data) from svg-captcha with captcha.text kept in the session.

Remediation

  1. Generate challenges with a cryptographic generator (crypto.randomInt, secrets).
  2. Keep the answer server side, keyed by a single-use id, and never include it in a response.
  3. Reject when the stored challenge is missing, then delete it after one attempt.
  4. Prefer an established service (reCAPTCHA, hCaptcha, Turnstile) over a home-grown CAPTCHA.

References

Suppressing this rule

Put a nosec comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file’s language (#, //, -- or ;):

# nosec vnx-804
// nosec vnx-804

Or record an ignore rule: vulnetix ignore add --rule vnx-804 --reason "...". See Suppressing findings.

esc
↑ ↓ move↵ openSearches in your browser. A key like autonomy.max or a code like threshold_required jumps straight to it.