squirrelscan
GitHub

HTML comments: what leaks in markup visitors never see

HTML comments reach every visitor. squirrel flags internal hosts, exposure notes, secrets and commented-out script, form or admin markup.

What leaks in an HTML comment

An HTML comment (<!-- ... -->) never shows on the page, but it is sent to every visitor and to every crawler. Internal hostnames, private IP addresses, TODO notes and commented-out admin markup tend to stay in comments long after the code around them ships. Each one tells an attacker how your infrastructure is laid out or where to look. security/leaked-secrets already reads comments for credentials. This rule covers the rest of what a comment can give away.

What squirrel checks

The rule runs on every crawled page and reads every comment node in the page’s HTML. It reads at most 500 comments per page and the first 20,000 characters of each. A comment is flagged when it holds any of these signals:

  • internal-host: a private or loopback IPv4 address (10.x.x.x, 172.16.x.x to 172.31.x.x, 192.168.x.x, 127.x.x.x, 169.254.x.x), localhost, a host ending in .internal, .local, .lan, .corp or .intranet, or a staging-style host whose first label is staging, stage, stg, uat, qa, preprod, sandbox, dev or test. The page’s own host is never flagged.
  • exposure-note: TODO, FIXME, HACK or XXX in capitals, or remove before, do not ship, password or debug in any case.
  • commented-out markup: a <script or <form tag, or a tag whose href, action, src, id or class contains admin.
  • secret: a value that the security/leaked-secrets matchers recognise. Keys that are public by design and informational matches are not counted.

These comments are never flagged: IE conditional comments (<!--[if IE]>...<![endif]-->), framework boundary markers (<!--[-->, <!--]-->, <!--$-->, <!--/$-->, Vue v-if placeholders), WordPress block comments (wp:), Knockout ko containers, Astro, <!--more-->, empty comments, and section markers such as Start of ..., End of ..., Google Tag Manager and Generated by ....

The result is a warning, html-comment-exposure, with N HTML comment(s) on <page URL> hold sensitive information. Each item names the comment by position (comment 3), lists its signals and quotes a snippet of at most 160 characters centred on the first signal. Any matched secret is replaced with [redacted] before the snippet is built, so the value is never stored in the report. A page with no flagged comment passes, including a page with no comments. At most 25 items are listed per page.

How to fix it

Delete the comment. Strip comments from production builds with your HTML minifier or template engine (for example removeComments in html-minifier-terser, or Jinja {# #} and ERB <%# %> comments, which never reach the browser). Rotate any secret that sat in a comment, because it stays in caches and archives after you remove it.

Rule IDsecurity/html-comment-exposure
CategorySecurity
ScopePer-page
Severitywarning
Weight4/10

Enable / disable

Disable this rule

[rules]
disable = ["security/html-comment-exposure"]

Disable all Security rules

[rules]
disable = ["security/*"]

Enable only this rule

[rules]
enable = ["security/html-comment-exposure"]

enable replaces the default ["*"], so this is the only rule selected. Leave disable out: a rule that matches any disable pattern is skipped even when enable names it. Only an enabled setting under a rule’s own [rule_options] table overrides both lists.

Check names by outcome

Each check name this rule can emit, by what it means to a tool comparing two audits. A problem check is a finding. A clean check says the rule ran over what it covers and found nothing; it clears the problem checks listed beside it, so a finding is fixed when the rule ran over the same scope and a clean check took its place. A not checked check says the rule did not evaluate, and never clears a finding.

Check nameOutcomeClears
html-comment-exposureProblem
html-comment-exposureCleanhtml-comment-exposure

Security findings ship in every audit next to the SEO, performance and agent experience rules. See Website security scan with AI for how an agent works through a report.

References

Check your site

Run squirrel audit https://nutshop.squirrelscan.com and open the Security section of the report. Every flagged comment is listed by page with its signals and a redacted snippet. Signed-out local audits need no account and cost nothing. Signed-in audits spend credits.

Type to search…

↑↓ navigate↵ openesc close