Skip to content
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

fix: [VIDECO-10247] Add CSP header #881

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions server/serverMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ const securityHeaders = helmet({
'cdnjs.cloudflare.com',
'assets.tokbox.com',
'www.google-analytics.com',
'https://unpkg.com/@vonage/client-sdk-video@2/dist/js/opentok.js',
'https://unpkg.com/@vonage/',
'static.opentok.com',
'www.googletagmanager.com',
'assets.adobedtm.com',
],
styleSrc: ["'self'", "'unsafe-inline'", 'cdnjs.cloudflare.com', 'assets.tokbox.com', 'static.opentok.com'],
styleSrc: [
"'self'",
"'unsafe-inline'",
'cdnjs.cloudflare.com',
'assets.tokbox.com',
'static.opentok.com',
],
connectSrc: ['*'],
Copy link
Collaborator

@beHaze beHaze Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would narrow the scope here too if possible from "*"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the OpenTok Playground tool has a CSP connect-src directives that includes '*'.

To get connect-src and image-src directives to work without '*', I need to specify this:

      connectSrc: [
        "'self'",
        '*.tokbox.com',
        '*.opentok.com',
        'www.google-analytics.com',
        'analytics.google.com',
        'stats.g.doubleclick.net',
        'wss:',
      ],
      imgSrc: [
        "'self'",
        'cdnjs.cloudflare.com',
        'www.googletagmanager.com',
        'data:',
      ],

Note that the 'wss:' directive for connect-src is given without a domain because the WebSocket URLs used by OpenTok.js are subject to change. (For example, currently when testing, I get a WSS URL of wss://media-sfu2-6444674bb5-vtc7q-us-west-2.media.prod.tokbox.com/rumorwebsocketsv2?socketId=c873c560-a30c-4c8e-83e0-3c3b93967812&attempt=18444deb-99b7-496e-a055-62af697fe0a0.)

I am tempted to leave these set to '*'. Wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more narrow the scope of the wildcards the better. If the app can continue to function properly I would keep 'em scoped down.

imgSrc: ['*', 'data:'],
},
Expand Down
Loading