Repository navigation
feat(rules): rate cookie-flags and token-storage higher and name the hosts when third-party scripts run on the page #2089 - #2260
Merged
Conversation
…hosts when third-party scripts run on the page #2089 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
marked this pull request as ready for review
November 22, 2026 23:05
This was referenced Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
security/cookie-flagsandsecurity/token-storagenow take into account who else runs code on the page. When the page's markup loads<script src>from another registrable domain, a session-like cookie withoutHttpOnlyand a token written to web storage are rated one step higher (warn to fail). The finding names up to five third-party script hosts and counts the rest. With no third-party script the output is byte-identical to today.Closes #2089
packages/rules/src/security/third-party-script-hosts.ts: executable<script src>outside<noscript>, resolved against the page URL, http(s) only, registrable domain different from the page (tldts, asisThirdPartyScriptalready did). It returns sorted, deduplicated hostnames.isThirdPartyScriptandEXECUTABLE_SCRIPT_TYPEmoved here, andtoken-storagere-exportsisThirdPartyScript.cookie-flags: session-like cookies (default session names such asPHPSESSID,JSESSIONID,connect.sid,*_session, plus any nametoken-storage'sisTokenKeyaccepts) move fromcookie-httponly(warn) into a newcookie-httponly-third-party-scripts(fail) check. Other cookies keep the warning. Platform and CSRF exemptions are unchanged.token-storage: findings on such a page fail instead of warning. For a write inside a third-party script, that script's own host is not counted. The external-scriptfoldKeyadds the host set, so a folded message never names a host a page does not load.site.externalAssets.externalAssetsis only present when another rule turns on the external probe, so it can't be relied on.security/cookie-flagsis added toREADS_PARSED_BUT_RUNSinunread-page-gate-1570.test.ts, with the reason given.Acceptance criteria
cookie-flags.test.ts, "a session cookie without HttpOnly fails and names the third-party hosts" and "names five hosts and counts the rest, sorted and deduplicated".docs/rules/security/cookie-flags.mdx,token-storage.mdx, new section "Third-party scripts on the page").Mutation check: forcing
thirdPartyScriptHoststo return[]fails 8 of the new tests, and the "unchanged" tests still pass. Expected values are literals, not imported constants.Gates
packages/rules:format:check,lint,typecheck(all three tsconfigs) pass.bun run scripts/test-suites.ts --run rules: 12658 pass, 0 fail (415 files).streaming-rules-canonical-golden,item-finding-identity,ignore-rule-cache-1262,ignore-timeout-cut-1419,build-headers-map: 31 pass.golden-finding-messages-229,docs-rule-pages,docs-category-table,apps/cli/tests/mcp/docs-sync: 16 pass.docs/:make validatepasses (tangly strict, links, glossary, rule-checks, 74 script tests).bun scripts/changelog.ts check: OK. Entrychangelog.d/2089-third-party-script-exposure.security.md.Agent skill
The squirrelscan agent skill may want a line saying the new
cookie-httponly-third-party-scriptscheck fails, and that token-storage findings can now be failures. This is noted for the maintainer; no skill change is in this PR.Hold-list (security rule severity): draft for planning review.