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
- 1Remove all HTML comments from production templates and views
- 2Configure your bundler or minifier to strip comments from HTML output
- 3Audit HTML output for <!-- comments --> before each deployment
- 4Use version control commit messages for developer notes instead
Code examples
Next.js: disable HTML comments in production
# 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.
More info disclosure checks
- MediumRails Session Cookie Missing HttpOnly Flag
- InfoServer header truncated
- InfoPHP session cookie naming exposes runtime
- Infoconfig.js / settings.js referenced (verify contents)
- Infoenv.js / environment.js referenced (verify contents)
- InfoSitemap.xml publicly accessible
- InfoOpenAPI schema version exposed in URL
- LowCORS exposes internal CDN hostname
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.