HTML Comments Information Disclosure
HTML comments in production can reveal sensitive information like TODOs, internal notes, or debug data.
Results in 1–3 minutes · Free · No signup required
Why It Matters
Developers often leave comments about vulnerabilities to fix, internal system details, or credentials. These help attackers understand your system.
How We Check
We scan HTML content for comments that might reveal sensitive information, internal paths, or security-related notes.
Good vs Bad Values
| Value | Verdict | Why |
|---|---|---|
No comments in the delivered HTML | Good | Minified output with comments stripped. Nothing for the check to read. |
<!--[if lt IE 9]> … <![endif]--> | Good | Conditional comments are ignored, as are Knockout markers and comments starting with google or Facebook. |
<!-- Footer start --> / <!-- end of header --> | Good | Structural labels with no sensitive words. They are not reported, only a size cost. |
<!-- TODO: remove admin password before launch --> | Bad | A TODO that mentions password, credential, auth or bypass is flagged. It also tells readers where to look. |
<!-- db: mysql://app:s3cret@10.0.3.12/shop --> | Bad | A connection string with a password and an internal address. Rotate the credential, not just the comment. |
<!-- api_key = AKIA… --> or token = <20+ chars> | Bad | Keys written as name=value pairs are high severity, and AWS key IDs are matched on their own prefix. |
<!-- build: 2024.18.3 deployed by jenkins on prod-web-04 --> | Weak | Build and deployment notes are low severity, but they give away the tooling and the host naming scheme. |
<!-- life hack: … --> or a comment mentioning redis in prose | Weak | The HACK marker and the database-name pattern are loose. Ordinary words can trigger them, so read the snippet shown in the report before acting. |
How to Fix
Strip HTML comments in your build process. Review remaining comments for sensitive information. Use server-side comments instead.
Write comments the template engine drops instead of HTML comments:
{# Jinja / Twig / Django: this never leaves the server #}
{{-- Blade comment --}}
<%# ERB comment %>
<?php /* PHP comment */ ?>
@* Razor comment *@
Strip them in the build. For a webpack HTML template:
new HtmlWebpackPlugin({
template: 'src/index.html',
minify: { collapseWhitespace: true, removeComments: true },
});
For static output from any tool, run an HTML minifier as the last step:
pnpm add -D html-minifier-terser
pnpm exec html-minifier-terser --remove-comments --collapse-whitespace -o dist/index.html src/index.html
Next.js and other React renderers do not emit your JSX comments, so keep notes as {/* … */} and not as raw HTML. WordPress — plugins sometimes print their own marker comments; search the page source for <!-- and check which plugin prints each one.
A note on server-side stripping: nginx sub_filter only replaces literal strings and cannot match a comment by pattern, so it is not a reliable way to remove them. Fix the source or the build.
If a comment held a secret, treat it as published. Rotate the credential, then remove the comment, because caches and crawlers keep old copies.
Verify: curl -s https://example.com/ | grep -c '<!--' should return a small number, and each remaining hit should be one you can defend. Repeat for the login and checkout pages.
Common Mistakes
- Using HTML comments for notes to colleagues. They are delivered to every visitor; use a comment syntax that the template engine removes.
- Stripping comments in the build of the main site but not in the CMS, error pages, or a widget that outputs its own HTML.
- Leaving a commented-out block of old markup, including the old form action or API URL. It still reveals paths and parameter names.
- Believing minification removes comments. Some minifiers keep comments that look like licenses or start with an exclamation mark.
- Checking only the home page. Login, checkout and error templates are written by different people and tend to carry more comments.
Frequently Asked Questions
What is HTML Comments Information Disclosure?
HTML comments in production can reveal sensitive information like TODOs, internal notes, or debug data.
Why does HTML Comments Information Disclosure matter for website security?
Developers often leave comments about vulnerabilities to fix, internal system details, or credentials. These help attackers understand your system.
How do I fix HTML Comments Information Disclosure issues?
Strip HTML comments in your build process. Review remaining comments for sensitive information. Use server-side comments instead.
Related Security Checks
Check Your Website Now
Run a free security scan to check for HTML Comments Information Disclosure issues and 61 other security checks.
Scan Your Website Free