Skip to content

fix(integrity): scan long control label windows #1424 - #1454

Closed
WilliamK112 wants to merge 1 commit into
squirrelscan:mainfrom
WilliamK112:codex/brand-attribute-tail-1424
Closed

WilliamK112 wants to merge 1 commit into
squirrelscan:mainfrom
WilliamK112:codex/brand-attribute-tail-1424

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary\n\n- keep the first 150 and last 149 normalized characters of long control attributes\n- count omitted middle content and content past the raw limit as unread\n- add regression coverage for aria-label, title, input value, logo alt, and an omitted-middle case\n- document the bound and add the user-visible change to the changelog\n\nCloses #1424\n\n## Verification\n\n- oxfmt --check on the changed TypeScript files\n- oxlint on the changed TypeScript files\n- packages/rules typecheck\n- 154 focused integrity tests\n- full rules suite: 8,641 passed, 25 todo, 0 failed\n- docs check\n- docs build\n\n## Checklist\n\n- [x] Tests added and passing\n- [x] No secrets or generated artifacts committed\n- [x] Commit carries DCO sign-off\n\nDocs: updated docs/rules/integrity/brand-impersonation.mdx.\nSkill: none.

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Thanks for taking on #1424 so quickly. An independent security review of this change is running now (the evasion shapes: a phrase in the omitted middle, a split phrase across the cut, unicode expansion at the cut, cost on pages with many long labels). We will comment here with the result, and if it is good we will cherry-pick it into the next release batch with your authorship kept.

nik

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Review result: thank you, the change fixes the exact example in #1424 and it is cheap (linear, same cost as main on 5 MB pages). Before we can take it we found two things with a probe that places the phrase at every start offset with 400 characters of padding after it:

  • A phrase at offset 131 to 280 is found on main and missed with the 150/149 cut (it only works from 0 to 130), so an attacker now needs 150 characters of padding on each side where before they needed 300. With an overlay on the page, main reports fail at offsets 200 and 280 and the PR drops it to an info note.
  • Any control with an attribute over 300 characters now counts as unread (before, only over 16,000), which gives a false info check on ordinary pages such as a link with a long title.

Suggested direction, which a maintainer lane will implement on top of your commit so your authorship stays: replace the head-and-tail cut with overlapping 300-character windows (stride 150) over the first 16,000 normalised characters, and mark an attribute unread only above 16,000. We prototyped it: the phrase is found at every offset from 0 to 420 with padding on both sides, and the worst-case time stays at 1.2 s. You are welcome to push that yourself; otherwise we will carry it.

nik

nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: e77d9b4

Verdict: pending maintainer review. The two blockers from the earlier maintainer review are still open on this head (no commits since), and CI is green (all checks pass, DCO sign-off present).

Earlier requested changes:

  1. Head-and-tail cut (150/149) misses a phrase at offsets 131 to 280, so it is easier to evade than main. Still open: boundedAttribute in packages/rules/src/integrity/controls.ts (new function near ATTR_HEAD_CHARS) keeps only the first 150 and last 149 normalised characters. The suggested fix is overlapping 300-character windows with stride 150 over the first 16,000 normalised characters.
  2. Any attribute over 300 characters now counts as unread (cut = ... || normalised.length > ATTR_CHARS, then paddedAttributes++), which gives a false info check on ordinary long titles. Still open: the unread threshold should be above 16,000 only.

Further findings:

Positives: linear cost, the logo alt is now bounded in the same way as other attributes, and the changelog entry and DCO are in place.

nik

@WilliamK112
WilliamK112 force-pushed the codex/brand-attribute-tail-1424 branch from e77d9b4 to a9e04bb Compare October 31, 2026 19:55
@WilliamK112 WilliamK112 changed the title fix(integrity): read both ends of long control labels #1424 fix(integrity): scan long control label windows #1424 Oct 31, 2026
@WilliamK112

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed probe. Addressed in a9e04bb:

  • replaced the head/tail sample with overlapping 300-character windows at stride 150
  • only records an unread attribute when the 16,000-character bound is exceeded
  • added coverage for every phrase offset from 0 through 420, a phrase crossing the old cut, NFKC expansion at offset 300, and the ordinary 400-character title case
  • kept coverage for aria-label, title, input value, and nested logo alt
  • removed the unrelated formatter churn and updated the docs/changelog wording

Validation: focused regression tests pass; rules typecheck and lint pass; the full rules suite reports 8,642 pass, 25 todo, 0 fail; docs checks pass.

nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: a9e04bb

Verdict: pending maintainer review. Both blockers from the earlier review are addressed on this head, CI is green and the DCO sign-off is present. I read the diff only (no probe run), so the cost question below needs a maintainer run before this is taken.

Earlier requested changes:

  1. Head-and-tail cut misses offsets 131 to 280. Addressed: boundedAttribute in packages/rules/src/integrity/controls.ts now emits overlapping 300-character windows at stride 150, so any phrase up to 150 characters sits whole in one window. The new test walks offsets 0 to 420 with 400 characters of padding after the phrase, and adds an NFKC expansion case.
  2. Any attribute over 300 characters counted as unread. Addressed: cut is only set past the 16,000 bound, and the "long ordinary title" test pins zero checks at 400 characters and one scanTruncated check at 16,001.
  3. Unrelated formatter churn and the confusables additions. Addressed: the diff is limited to controls.ts, one test file, the rule doc and the changelog.
  4. Changelog and rule doc wording. Addressed: both describe the windows, and the integrity/brand-impersonation: an attribute label padded with real characters before the phrase is cut at 300 #1424 known limit is removed from the doc.

Further findings:

  • Medium: cost is not shown. An attribute now yields up to about 106 windows of 300 characters instead of one string, per attribute per control, and the controls cap is 60,000. Please run the many-controls-with-16,000-character-labels probe (and a page of 5 MB of such controls) against main to confirm the 1.2 s worst case holds with this implementation, and check that the matcher over extra is not quadratic in the window count.
  • Low: windows start at fixed offsets, so a window can begin mid-word. A label containing Redesign in with Google Workspace whose window starts at sign would match as whole words. The outcome is a single-signal info at worst, but snapping a window start to the next word boundary (the overlap already covers the phrase) would remove it.
  • Low: in boundedAttribute, normalised.length > ATTR_RAW_CHARS is always false because normalised comes from text.slice(0, ATTR_RAW_CHARS). The cut flag is effectively text.length > ATTR_RAW_CHARS. Harmless, but the dead branch and the "before it is cut to ATTR_CHARS" comment on ATTR_RAW_CHARS are stale.
  • Low: the window test places padding only after the phrase for offsets 0 to 420. Padding on both sides, as in the earlier probe, would also be worth pinning.

Positives: the maintainer's suggested design was followed, the tests cover the exact failure shapes from the review, and the PR is scoped to #1424.

nik

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Thank you for the rewrite: the overlapping-window version fixes every finding from our first review (the phrase is found at every offset up to 15,960, unread is flagged only above 16,000, no head and tail glue, no formatter churn) and we will carry it with your commit and authorship kept. We are adding one maintainer commit on top for the remaining items: snapping window edges to word boundaries (a phrase like "design in with Google Workspace" can hit at a window seam), a fail-safe page budget so many decoy controls cannot starve the real one, and docs. No change is needed from you.

nik

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Landed in v0.0.152 as c09396f9 (William's commit) plus a maintainer follow-up 794e1dc3, via #1461 and #1455. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.152. Thank you William: the long control label windows from this PR are in the release with your authorship intact. Closing as superseded by #1455.

nik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants