URL: /rules/security/html-comment-exposure

---
title: "HTML comments: what leaks in markup visitors never see"
description: "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](/rules/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](/rules/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 ID** | `security/html-comment-exposure` |
| **Category** | [Security](/rules/security) |
| **Scope** | Per-page |
| **Severity** | warning |
| **Weight** | 4/10 |

## Enable / disable

### Disable this rule

```toml squirrel.toml
[rules]
disable = ["security/html-comment-exposure"]
```

### Disable all Security rules

```toml squirrel.toml
[rules]
disable = ["security/*"]
```

### Enable only this rule

```toml squirrel.toml
[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.

{/* rule-checks:start */}

| Check name | Outcome | Clears |
| --- | --- | --- |
| `html-comment-exposure` | Problem |  |
| `html-comment-exposure` | Clean | `html-comment-exposure` |

{/* rule-checks:end */}

## Related rules

- [security/leaked-secrets](/rules/security/leaked-secrets): secrets in HTML, comments, scripts and source maps.
- [security/version-disclosure](/rules/security/version-disclosure): software versions that a page or header gives away.

Security findings ship in every audit next to the SEO, performance and agent experience rules. See [Website security scan with AI](https://squirrelscan.com/learn/audit-website-security-with-ai) for how an agent works through a report.

## References

- [Information exposure through comments, CWE-615](https://cwe.mitre.org/data/definitions/615.html)

## 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.

<CardGroup cols={2}>
  <Card title="Install squirrel" icon="terminal" href="/quickstart">
    One command to install, one to run your first audit.
  </Card>
  <Card title="See a sample report" icon="file-text" href="https://squirrelscan.com/reports/squirrelscan-sample">
    What the Security section looks like on a real site.
  </Card>
</CardGroup>
