Repository navigation
fix(rules): read integrity auth cues across element boundaries #696 - #749
Conversation
|
Held for maintainer review: this closes a detection-evasion gap (security label), so it is not auto-merged. CI and review are the lane's to confirm; merge is Nik's call. |
|
Review of #749: reads brand/auth cues from element-separated text as well as glued text. The change is small and well scoped. I read the diff and the
I found no critical or high issues. The CHANGELOG and docs updates match the behaviour. |
7309c31 to
3edb9e9
Compare
|
Review of #749: the fix looks correct and well scoped. I read the diff only and did not run the tests.
No blocking issues. |
|
Review of #749: the change looks correct and I found nothing blocking.
Test coverage is good. The new tests cover the glued and spaced cases, newline, nbsp, br and invisible characters in the label, plus the negative cases for verify-only and continue-with-only links. The CHANGELOG and docs are updated. |
detectBrandImpersonation gated on a word-bounded "sign in" test over `content.textContent`, which glues adjacent elements: with no whitespace between `<h1>Applicability fixture</h1>` and an off-brand "Sign in with Google" link the text read "fixturesign in", the gate failed, brand-impersonation never fired and a correlated fake-auth-overlay dropped from fail to info. Read the title and copy for the auth and brand cues from the glued text and the element-separated text (getPageSeparatedText from #739), in brand-impersonation and in fake-auth-overlay's page-level corroboration, and count a sign-in control's own label (credentialDestinations) as a credential affordance. Every test on that haystack asks whether a cue appears, so the extra text can only find one. seo-doorway is untouched: its word counts would change. Adds the reporter's integrity-text-boundary.test.ts plus the cases the fix must not change (legit Google link, self-hosted link, bare brand mention, lone signal). Signed-off-by: Nik Cubrilovic <[email protected]>
…mpty-body branch #739 Follow-up to the #748 review nits: say the per-document cache assumes a read-only DOM, and assert "" for a document with no body instead of only the return type. Signed-off-by: Nik Cubrilovic <[email protected]>
…n affordance #696 Security review follow-up. A newline, double space, , <br> or a zero-width character inside a link's label still hid "Sign in with Google": read each label as written and element-separated, invisible characters removed and whitespace collapsed, and the page haystack the same way. The credential-affordance gate counted every auth-labelled link, so a lone "Verify your Google account" link to a third party could fire; only a label that says sign in or log in counts now. Memoise the haystack per document. Signed-off-by: Nik Cubrilovic <[email protected]>
…character #696 Delta review: reading every anchor's label in full twice grew with the square of nested unclosed anchors (2,000 took 1.5 to 3.6 s, past the rule budget), so junk markup could hide a real signal. Skip a link whose text is over 300 characters, and skip the element-separated read for a text-only link. Strip Unicode's whole default-ignorable set (U+2063, U+034F were missed). Tests time nested anchors at n, 2n and 4n. Signed-off-by: Nik Cubrilovic <[email protected]>
063b5c9 to
6f48142
Compare
|
Review of #749. The fix is sound and the false-positive guards are preserved. Two things to look at, plus nits. I read the diff only and did not run the tests.
|
… skip it #696 Delta review: skipping a label over 300 characters let a kit pad one (a <style>, an SVG title, sr-only text) and evade both rules, where main read it. Read a long label as main did, lowercased, and skip only the normalisation and the element-separated read. The timing test now measures the detector against a bare textContent loop over the same anchors, so both see the same machine load. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review of #749. I read the diff only and did not run the tests. The fix looks correct and well scoped. Reading the cues from both the glued and the element-separated text can only add matches, so it closes the evasion gap in #696 without touching the false-positive guards. The tests cover the reporter's repro, the unchanged controls, and invisible-character and whitespace splits inside the label.
No blocking issues. |
Closes #696.
Security note (hold-list): #696 is labelled
security. This PR closes a detection-evasion gap. A phishing page could stopintegrity/brand-impersonationfrom firing, and downgrade a correlatedfake-auth-overlayfrom fail to info, just by removing the whitespace between its elements. Nothing else about the kit had to change. The fix only widens what the detectors can see (the extra text can find a cue, never hide one). The false-positive guards are unchanged: a brand-labelled control with an off-brand destination, and the two-signal escalation gate.What changed
detectBrandImpersonation(packages/rules/src/integrity/signals.ts) gated everything on a word-boundedsign intest over the title andcontent.textContent. That text glues adjacent elements: with no whitespace between<h1>Applicability fixture</h1>and the off-brand "Sign in with Google" link it readfixturesign in with google. The gate failed before the link's own evidence was considered,brand-impersonationnever fired, and the correlatedfake-auth-overlaydropped from fail to info.authHaystack(ctx)reads the auth and brand cues from the glued text and the element-separated text (getPageSeparatedText, from schema/rating-scope, integrity/kit-signature: element-glued text breaks word-boundary checks #739 / fix(rules): read element-separated text in schema/rating-scope #739 #748). It is used bydetectBrandImpersonationand bydetectFakeAuthOverlay's page-level auth corroboration. Every test on that haystack asks whether a cue appears, so the extra text can only find a cue, never hide one.credentialDestinationsonly returns password forms and links whose own text matchessign in,log in,login,continue withorverify, so a missing page-wide word boundary no longer overrides that evidence.detectSeoDoorway. The doorway detector computes word counts and keyword density from its text, which a second copy would change.extractContentstill feedswordCount,contentHashandisThinContentexactly as before.Acceptance criteria
The reporter's
packages/rules/tests/integrity-text-boundary.test.tsis added as filed and passes. The compact markup now yields bothbrand-impersonationandfake-auth-overlay.fake-auth-overlayreportsfailwith the correlated brand signal, with or without whitespace.The text read by
detectPageSignalshas a boundary at every element, via the sharedgetPageSeparatedText.No new false positives: the existing integrity suites pass unchanged (
integrity.test.ts,integrity-cloaking.test.ts,integrity-intel.test.ts; 94 tests with the new file). New guard cases cover:accounts.google.comlink (no signal);streaming-collector-rules-goldenandstreaming-rules-canonical-goldenpass with no re-pin.Other readers of the same text:
schema/rating-scope: fixed in schema/rating-scope, integrity/kit-signature: element-glued text breaks word-boundary checks #739.integrity/kit-signature: unaffected, documented and pinned in schema/rating-scope, integrity/kit-signature: element-glued text breaks word-boundary checks #739.integrity/seo-doorway: deliberately left on the glued text (word counts).audit-engine/src/cloud-prefetch-run.tstextExcerpt: not a rule.On main, three of the nine tests in the new file fail: the reporter's regression, the lone off-brand link, and the glued off-self overlay corroboration. I checked that by swapping main's
signals.tsback in.Verification
bun test packages/rules/tests/integrity.test.ts packages/rules/tests/integrity-cloaking.test.ts packages/rules/tests/integrity-intel.test.ts packages/rules/tests/integrity-text-boundary.test.ts: 94 pass (103 withglued-element-text.test.ts).bun test packages/audit-engine/tests/streaming-collector-rules-golden.test.ts: pass.bun test packages/audit-engine/tests/streaming-rules-canonical-golden.test.ts: pass, no re-pin.tsgo --noEmitinpackages/rules: clean. oxlint's one error insignals.ts(no-object-as-default-parameteratopts = {}) and its oxfmt drift are both pre-existing on main and outside this diff.docs/rules/integrity/brand-impersonation.mdxandfake-auth-overlay.mdxdescribe the boundary-aware reading.make validatepasses.Security review follow-up (063b5c9)
An Opus security review of the rebased head found two issues, both fixed here.
brand-impersonation(info, or fail with a second signal). That contradicted "the false-positive guards are unchanged". Now only a link whose own label sayssign in,log inorlogincounts as an affordance on its own, which still covers the reporter's case. ,<br>, a spacer span, U+200B or a soft hyphen inSign in with Google. Each label is now read as written and element-separated, with invisible characters removed and whitespace collapsed, and the page haystack is read the same way.Two new tests cover these: seven label variants fire, and the verify / continue-with links stay silent. Both fail on 3edb9e9 and pass now.
The reviewer's remaining items predate this PR and are filed separately: label only in an attribute,
<button>/<input>controls, "Continue with Google" missing from the lexicon, homoglyphs, identity brokers (Auth0, Okta) read as impersonation, and a few Microsoft hosts.Also in this PR
Two #748 review nits on the shared helper it now has a second consumer for:
getPageSeparatedTextdoc comment says the per-document cache assumes a read-only DOM;""instead of only the return type.Agent skill
No change needed.