Repository navigation
Description
Summary
Removing one inter-element space suppresses the brand-impersonation signal and downgrades a correlated fake-auth-overlay finding from fail to info. Both fixtures contain the same full-viewport auth iframe and the same off-brand “Sign in with Google” link.
Reproduction scope. Source-level regression test against the unmodified v0.0.108 tag, commit c456496, using the actual parsePage and rule implementations. This is not a published CLI end-to-end replay. Install scripts were disabled; no outbound requests are made by these parser/rule tests.
Add the following file as packages/rules/tests/integrity-text-boundary.test.ts in the upstream repository:
import { expect, test } from "bun:test";
import { parsePage } from "@squirrelscan/parser";
import { detectPageSignals } from "../src/integrity/signals";
import { brandImpersonationRule } from "../src/integrity/brand-impersonation";
import { fakeAuthOverlayRule } from "../src/integrity/fake-auth-overlay";
import type { RuleContext } from "../src/types";
const url = "https://example.com/";
const overlay = '<iframe id="google-auth" srcdoc="" style="position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999"></iframe>';
const link = '<a href="https://credential-fixture.invalid/signin">Sign in with Google</a>';
function context(body: string): RuleContext {
const html = `<!doctype html><html><head><title>Applicability fixture</title></head><body><main><h1>Applicability fixture</h1>${body}</main></body></html>`;
const parsed = parsePage(html, url);
return { page: { url, html, statusCode: 200, loadTime: 0, headers: {}, parsed }, parsed, options: {} };
}
test("control: whitespace-separated correlated signals produce two failures", () => {
const ctx = context(` ${overlay}${link}`);
expect([...detectPageSignals(ctx)].sort()).toEqual(["brand-impersonation", "fake-auth-overlay"]);
expect(brandImpersonationRule.run(ctx).checks[0]?.status).toBe("fail");
expect(fakeAuthOverlayRule.run(ctx).checks[0]?.status).toBe("fail");
});
test("regression: removing inter-element whitespace preserves correlated signals", () => {
const ctx = context(`${overlay}${link}`);
expect([...detectPageSignals(ctx)].sort()).toEqual(["brand-impersonation", "fake-auth-overlay"]);
expect(brandImpersonationRule.run(ctx).checks[0]?.status).toBe("fail");
expect(fakeAuthOverlayRule.run(ctx).checks[0]?.status).toBe("fail");
});
test("control: a lone overlay remains info", () => {
const ctx = context(` ${overlay}`);
expect([...detectPageSignals(ctx)]).toEqual(["fake-auth-overlay"]);
expect(fakeAuthOverlayRule.run(ctx).checks[0]?.status).toBe("info");
expect(brandImpersonationRule.run(ctx).checks).toEqual([]);
});
test("control: an ordinary iframe has no compromise signal", () => {
const ctx = context(' <iframe title="Ordinary content" srcdoc="" style="width:300px;height:150px"></iframe>');
expect([...detectPageSignals(ctx)]).toEqual([]);
expect(fakeAuthOverlayRule.run(ctx).checks).toEqual([]);
expect(brandImpersonationRule.run(ctx).checks).toEqual([]);
});Run: bun test packages/rules/tests/integrity-text-boundary.test.ts.
Actual (Bun 1.3.11, source test, 2026-10-12): three controls pass; the compact-markup regression fails because detectPageSignals returns only fake-auth-overlay instead of brand-impersonation plus fake-auth-overlay. The spaced control produces two fail checks. The single-overlay control remains info; the ordinary iframe produces no signal.
Cause. The exported parsePage uses extractContent in src/html.ts, which clones the body, removes scripts/styles and reads clone.textContent without block separators. The compact fixture becomes Applicability fixtureSign in with Google. In detectBrandImpersonation, the page-wide hasCredentialAffordance word-boundary regex fails before the independently labelled credential link is considered. The link's own text is still Sign in with Google; its destination remains off-brand.
Expected. Inter-element whitespace must not determine whether an explicitly brand-labelled, off-brand credential control is recognized. Preserve the ordinary iframe, the lone-signal info behavior, legitimate provider links and self-hosted authentication. A missing page-wide word boundary should not override the credential control's own evidence. No new network probes are needed.
Local action. No rule disabled and no production/Overhub detection changed. Existing zero-check localhost runs do not prove integrity is disabled: this fixture loses correlation, and lone info findings also meet the separately tracked report visibility limitation #669. Published CLI confirmation remains separate from this source-level reproduction.
The existing integrity.test.ts suite also passes: 68 tests, 138 assertions. The reproduction and corrected source attribution were independently reviewed before filing.
Acceptance Criteria
- The reporter's regression test (
integrity-text-boundary.test.ts) is added and passes: removing inter-element whitespace between the auth iframe and the off-brand "Sign in with Google" link still yields bothbrand-impersonationandfake-auth-overlaysignals. -
fake-auth-overlaystill reportsfail(notinfo) when the correlated brand signal is present, with or without whitespace. - Text extraction used by
detectPageSignalsinserts a boundary between adjacent block/inline-block elements so words from different elements are not glued together. - No new false positives: existing integrity rule tests and the streaming-rules canonical golden test pass unchanged (or the golden change is explained in the PR).
- Any other rule built on the same text extraction is checked for the same gluing bug, and the result is noted in the PR.
Activity
nc9 commentedon Oct 13, 2026
Spec prep
Verdict: confirmed on current main (
e95e0f5, v0.0.112). Confirmed by reading the code; the reporter's test was not re-run.packages/parser/src/html.ts:379-417(extractContent) still clones<body>, drops scripts and styles, and readsclone.textContentwith no separators. The compact fixture becomesApplicability fixtureSign in with Google.packages/rules/src/integrity/signals.ts:247-300(detectBrandImpersonation) gates everything onhasCredentialAffordance: a password input, or/\b(sign in|log in|login|enter your password|verify your account)\b/overtitle + "\n" + content.textContent. Infixturesign inthere is no\bbeforesign, so it returnsnull.credentialDestinations()has already found the link, labelled it Google from its own text, and resolved an off-brand host. That evidence is computed and then ignored.detectFakeAuthOverlayhas the same page-wide test (pageHasAuthAffordance,signals.ts:412-418), which its off-self iframe branch needs. In this fixture the overlay still fires through thegoogle-authid, which is why it drops toinfoinstead of vanishing.Change (in
signals.tsonly, no parser change)credDestsbefore the gate, and treatcredDests.length > 0as a credential affordance. Every entry is already either a password form or a link whose own text matchesAUTH_LABEL. This alone fixes the reporter's regression.signalText(ctx), memoised perDocumentin aWeakMapthe same waysignalCacheis. Use it in place ofctx.parsed.content.textContentindetectBrandImpersonation,detectFakeAuthOverlayanddetectSeoDoorway. Build it onpackages/rules/src/content/text-content.ts:getRenderedProseText(body)puts a newline at each block boundary and skipped subtree, which covers this fixture (h1is a block).iframe,img,input,button,select,textarea) as boundaries too, but not every inline node.<span>Goo</span><span>gle</span>should still read asgoogle, as a browser shows it.getSeparatedTextsplits every node, so it would lose that.extractContentalone. ItstextContentfeedswordCount,contentHash(duplicate content,page_features.content_hash, the rule cache key),isThinContentand the cloudtextExcerpt. A parser-wide boundary fix is a separate, much larger change; file a follow-up if we want it.Criterion 5: other readers of
parsed.content.textContentintegrity/kit-signature.ts:55passes it astextto intel signature matching. Same gluing. Switch it tosignalTextin the same PR.schema/rating-scope.ts:353(visibleText) runsVISIBLE_RATING_PATTERNS, which are\b-anchored, over it.<span>Rating</span><span>4.8</span>readsRating4.8, so a visible rating can be missed and give a false "not visible" warning. This is a real candidate: fix it here or file a follow-up (see open questions).audit-engine/src/cloud-prefetch-run.ts:101(textExcerpt) is not a rule.content/*rules already read text through thetext-content.tshelpers, so they are not affected.Tests
packages/rules/tests/integrity-text-boundary.test.tsverbatim (4 tests). Add:Sign in with Googlelink toaccounts.google.com: nobrand-impersonation;brand-impersonationsignal alone, atinfo;Sign in with <span>Goo</span><span>gle</span>), pinning whichever behaviour we choose.integrity.test.ts(68 tests),integrity-cloaking.test.tsandintegrity-intel.test.tswith explicit paths.packages/audit-engine/tests/streaming-collector-rules-golden.test.ts(integrity/orphan-pageandtemplate-discontinuityreaddetectPageSignalsthroughcollected-signals.ts), thenstreaming-rules-canonical-golden.test.ts. Both compare v1 with v2 running the same code, so I expect them green. If the seeded fixture's tally moves, explain it in the PR.Docs, skills, completions
docs/rules/integrity/brand-impersonation.mdxandfake-auth-overlay.mdx: one sentence each saying page copy is read with element boundaries and that a brand-labelled sign-in control counts as auth copy on its own. Runmake validate.Risks
sign inmatch where glued text hid one, so a few pages may gain a signal.failstill needs two distinct signals, and brand impersonation still needs a brand-labelled control with an off-brand destination. The false-positive guard stays where it is.Open questions for the maintainer
schema/rating-scopein this PR, or file a separate issue? I recommend a separate issue: it is a different rule family with its own fixtures.Recommended session
Sonnet, high effort (detection heuristics with false-positive guards). Size M confirmed. It would be S if limited to change 1.
fix(rules): schema/rating-scope reads adjacent elements as separate t…
fix(rules): read integrity auth cues across element boundaries #696
fix(rules): normalise integrity cue labels; only a sign-in label is a…
fix(rules): read integrity auth cues across element boundaries #696
fix(rules): normalise integrity cue labels; only a sign-in label is a…
fix(rules): cap integrity label reads; strip every default-ignorable …
fix(rules): read a long integrity label without the extra passes, not…
fix(rules): read integrity auth cues across element boundaries #696 (#…