Skip to main content
MediumInfo disclosureOWASP A05:2021CWE-615

How to fix: Credentials or keys embedded in HTML comments

HTML comments in the page source contain potentially sensitive information such as developer notes, internal paths, or debug data.

Why it matters

HTML comments are visible to anyone who views the page source. Developer notes in comments can reveal internal architecture, incomplete security fixes, API endpoints, or credentials that were left during development.

HTML comments (<!-- ... -->) are stripped by minifiers in production builds but frequently remain in server-rendered or manually edited pages. They are the first place attackers look for reconnaissance information.

How to fix it

  1. 1Remove all HTML comments from production templates and views
  2. 2Configure your bundler or minifier to strip comments from HTML output
  3. 3Audit HTML output for <!-- comments --> before each deployment
  4. 4Use version control commit messages for developer notes instead

Code examples

Next.js: disable HTML comments in production

bash
# HTML minifier options in next.config.mjs:
export default {
  experimental: {
    optimizeCss: true, // also strips some comments
  },
};

# Or audit for comments before deploy:
grep -rn "<!--" app/ --include="*.html" --include="*.tsx"

References

Detected automatically by VulnRadar. The check id is html-comment-leaks, stable across every scan so you can filter or diff on it.

See every info disclosure check

Questions

How severe is Credentials or keys embedded in HTML comments?
VulnRadar rates this medium severity in the info disclosure category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id html-comment-leaks, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Credentials or keys embedded in HTML comments map to?
It maps to CWE-615. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for credentials or keys embedded in html comments

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

Credentials or keys embedded in HTML comments | VulnRadar