Page MenuHomePhabricator

Content Security Policy now breaks use of iNaturalist API on Commons
Closed, ResolvedPublicBUG REPORT

Description

I imagine this is due to the recent security breach on Meta, but whatever changes were made to the Content Security Policy seem to have broken communication between Commons and iNaturalist. This means it is no longer possible to use the iNaturalist2Commons tool, which is frequently used there. (It's been used to import 190,918 files over the past 7 years).

Steps to replicate the issue (include links if applicable):

What happens?:

It gives the error "Error: Loading images failed. If you are using a privacy plug-in like Privacy Badger, you may need to adjust your settings."

In the Javascript console, it gives the following error:
Content-Security-Policy: The page’s settings blocked the loading of a resource (connect-src) at https://api.inaturalist.org/v1/observations?photo_license=cc0%2Ccc-by%2Ccc-by-sa&quality_grade=research&taxon_id=153516&per_page=84 because it violates the following directive: “default-src 'unsafe-eval' 'unsafe-inline' 'self' data: blob: https://*.wikimedia.org https://*.wikipedia.org https://*.wikinews.org https://*.wiktionary.org https://*.wikibooks.org https://*.wikiversity.org https://*.wikisource.org https://wikisource.org https://*.wikiquote.org https://*.wikidata.org https://*.wikifunctions.org https://*.wikivoyage.org https://*.mediawiki.org https://mediawiki.org https://wikimedia.org https://*.wmflabs.org https://*.wmcloud.org https://*.toolforge.org https://*.jsdelivr.net https://unpkg.com https://cdnjs.cloudflare.com https://raw.githubusercontent.com https://*.github.com https://code.jquery.com https://cdn.mathjax.org https://use.typekit.net https://fonts.cdnfonts.com https://use.fontawesome.com https://i.ytimg.com https://rsms.me https://doi.org https://localhost https://localhost:* http://localhost:* https://*.google.com https://*.gstatic.com https://*.googleapis.com https://*.translate.yandex.net https://yastatic.net https://ya.ru https://radically.github.io https://cdn.sammdot.ca https://cdn.fontshare.com https://viaf.org https://publicai-proxy.alaexis.workers.dev https://iiif.archive.org https://api.flickr.com https://live.staticflickr.com https://api.anthropic.com https://api.openai.com https://api.publicai.co https://catalogo.pusc.it https://parsifal.urbe.it https://opac.sbn.it https://overpass-api.de https://api.openrouteservice.org https://archive.org https://*.openstreetmap.org https://*.waymarkedtrails.org https://*.thunderforest.com” jquery.js:9940:10

What should have happened instead?:
It should allow communication with the iNaturalist API.

Other information (browser name/version, screenshots, etc.):
Firefox and Chrome tested.

Event Timeline

Probably we just need to add "https://api.inaturalist.org" to whatever whitelist is being used in that console error.

https://wikilovesinat.netlify.app/ still appears to be working if you need a tool in the mean time.

This (and other tasks) could be resolved with connect-src: http: which should allow loading JSON just fine. Note that changing default-src will change script-src and in turn script-src-elem which would allow easy loading and executing scripts directly from that domain. So you probably do not want that when you only need to allow downloading JSON. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/script-src-elem

Change #1251550 had a related patch set uploaded (by SBassett; author: SBassett):

[operations/puppet@production] Allow-list some additional domains to the currently enforcing CSP

https://gerrit.wikimedia.org/r/1251550

Change #1251550 merged by BCornwall:

[operations/puppet@production] Allow-list some additional domains to the currently enforcing CSP

https://gerrit.wikimedia.org/r/1251550

neriah assigned this task to sbassett.