-
Notifications
You must be signed in to change notification settings - Fork 0
fix(csp): allow the YouTube embed host on every variant (guide videos blocked after client-side navigation) #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,3 +178,31 @@ describe("applyCsp", () => { | |
| expect(res.headers.get("Content-Security-Policy")).toContain("frame-ancestors 'none'"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("frame-src — YouTube guide embeds", () => { | ||
| // A CSP belongs to the document, not the route: a client-side navigation from | ||
| // the landing page into /documents keeps the landing page's policy. Gating | ||
| // the YouTube frame host to the docs variant therefore blocked every guide | ||
| // video reached by clicking (Chrome: "This content is blocked"), while a | ||
| // direct load of the same URL worked. The host must be on every variant. | ||
| it.each<CspVariant>(["base", "admin", "store", "docs"])( | ||
| "allows the privacy-enhanced YouTube host on the %s variant", | ||
| (variant) => { | ||
| const frameSrc = directive(buildCsp({ nonce: NONCE, variant }), "frame-src"); | ||
| expect(frameSrc).toContain("https://www.youtube-nocookie.com"); | ||
| expect(frameSrc).toContain("'self'"); | ||
| }, | ||
| ); | ||
|
|
||
| it("does not widen frame-src beyond the known hosts", () => { | ||
| const frameSrc = directive(buildCsp({ nonce: NONCE, variant: "base" }), "frame-src"); | ||
| expect(frameSrc.split(" ").slice(1).sort()).toEqual( | ||
| [ | ||
| "'self'", | ||
| "https://*.clerk.accounts.dev", | ||
| "https://challenges.cloudflare.com", | ||
| "https://www.youtube-nocookie.com", | ||
| ].sort(), | ||
|
Comment on lines
+198
to
+205
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Apply the exact allowlist check to every variant. The test verifies the exact known-host set only for 🤖 Prompt for AI Agents |
||
| ); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the
YOUTUBE_FRAME_HOSTcomment.frame-srcalso allowshttps://challenges.cloudflare.comandhttps://*.clerk.accounts.devon Line 107. Therefore, this is not the only third-party frame origin. State that it is the only third-party YouTube frame origin.🤖 Prompt for AI Agents