Skip to content

waf-detect: an unclosed <code> hides the rest of the page from block-page wording #904

Closed

Description

@nc9

Follow-up from the review of #884 (#693).

signatureViews in packages/waf-detect/src/views.ts drops the text inside <code>, <kbd> and <samp> from the text view, so a page that quotes a block-page line in a code block is not attributed to the WAF. It counts how deep it is inside those elements, and the count only goes down on their closing tags. An unclosed <code> therefore hides the rest of the 10 KB sample from the text view. The HTML parser would have closed it at the next block boundary.

If a real block or challenge page has a stray <code> before its wording (a Cloudflare ray id, an Imperva incident line, CloudFront's footer), it is no longer recognised from that wording. Its markup signatures (scripts, ids) are unaffected.

Acceptance Criteria

  • An unclosed <code>, <kbd> or <samp> stops hiding text at the next block-level boundary (for example </p>, </div>, </pre>, </li>, </td>, </body>), as the HTML parser closes it
  • Test: a block page with a stray <code> before its incident line is still attributed to the provider
  • Test: a properly closed <pre><code> quoting the same line is still not attributed

Activity

  1. added
    bug
    size: XS
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsize: XS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions