Skip to content

fix: allow Google Picker scripts in CSP#2307

Merged
aalemayhu merged 1 commit into
mainfrom
fix/csp-allow-google-picker
May 15, 2026
Merged

fix: allow Google Picker scripts in CSP#2307
aalemayhu merged 1 commit into
mainfrom
fix/csp-allow-google-picker

Conversation

@aalemayhu
Copy link
Copy Markdown
Contributor

@aalemayhu aalemayhu commented May 15, 2026

What

Adds `https://apis.google.com\` and `https://accounts.google.com\` to the `script-src` directive of the CSP meta tag in `web/index.html`. Required for the Google Drive upload tab from #2306 to function.

Why

Browser console on prod after deploying #2306 showed:

```
Loading the script 'https://apis.google.com/js/api.js' violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' https://www.googletagmanager.com https://www.google-analytics.com https://static.hotjar.com https://script.hotjar.com https://www.dropbox.com"
```

Same violation for `accounts.google.com/gsi/client`. Both are required by the Picker / GIS flow that `useGooglePicker` lazy-loads.

How

One-line addition to the existing CSP meta tag's `script-src`. No other directives needed — frame/connect/img directives are not set on this site, so the Picker iframe and XHR calls were never blocked.

Testing

  • Local: rebuild + smoke-test the upload form. Tab opens the Picker.
  • Prod (after rebuild): browser console shows no CSP violations for the two Google origins.

Risks

  • Two new third-party script origins in script-src — both are Google-owned and serve the official Picker SDK; this is the same trust boundary as the existing Dropbox SDK allowance (`www.dropbox.com`).
  • Rollback: revert this commit. The CSP returns to its prior shape; the Drive tab silently fails to load Picker, same as before this fix.

Goal alignment

Unblocks #2306, which closes the empty "From Google Drive" history section #2305 introduced.


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Adds https://apis.google.com and https://accounts.google.com to the CSP
meta tag's script-src directive so the Google Drive upload tab from #2306
can actually load gapi/Picker and Google Identity Services. Without this,
"Choose from Google Drive" throws "Couldn't load Google Drive" because the
two <script> tags injected by useGooglePicker are blocked at the browser
boundary.

Verified in prod browser console — both scripts were blocked with the
exact CSP violation message before this change.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@aalemayhu aalemayhu merged commit da55e1b into main May 15, 2026
7 checks passed
@aalemayhu aalemayhu deleted the fix/csp-allow-google-picker branch May 15, 2026 22:41
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.

1 participant