Skip to content

Conversation

@imsodin
Copy link
Member

@imsodin imsodin commented Nov 1, 2020

Just noticed through #7079 that there's a method whitelist and thus added the new methods used in the /rest/config endpoints. And this also fixes an issue with /rest/config the only endpoint added in #7001 that I didn't add a test for. Weirdly enough adding the test wouldn't have helped: It doesn't fail (neither does the UI, which uses it too), while it does fail using curl. Anyway, works with curl too now.

@acolomb
Copy link
Member

acolomb commented Nov 1, 2020

That whitelist applies only to cross-origin requests AFAIK. Regular GUI usage is not affected by that, since the script making the requests comes from the same origin as the request target URL. As far as I understand, the browser takes care of disallowing requests from other script origins. So curl not doing it would be expected, since the "origin" is the user's command line.

Does that make sense? I'm no expert on CORS, and don't quite see what security is gained by the headers Syncthing sends...

@calmh
Copy link
Member

calmh commented Nov 1, 2020

Afaik this does not improve security, it on the contrary allows requests from non-GUI origins that would otherwise be blocked by the browser. For example, some Javascript running somewhere using the API key to do things.

@calmh calmh merged commit 4d1bcd7 into syncthing:main Nov 1, 2020
@imsodin imsodin deleted the api/fixconfig branch November 1, 2020 20:57
@acolomb
Copy link
Member

acolomb commented Nov 1, 2020

Afaik this does not improve security, it on the contrary allows requests from non-GUI origins that would otherwise be blocked by the browser. For example, some Javascript running somewhere using the API key to do things.

I meant I don't see what security gain the CORS check brings for Syncthing. As it effectively poses no restrictions, even more so with this change. Having the API open for all script origins is okay, I just wasn't sure if this function in Syncthing was actually meant to increase security somehow.

@calmh calmh added this to the v1.12.0 milestone Nov 3, 2020
calmh added a commit to calmh/syncthing that referenced this pull request Nov 9, 2020
* main:
  lib/folder: Clear pull errors when nothing is needed anymore (syncthing#7093)
  lib/api: Fix debug endpoints (ref syncthing#7001) (syncthing#7092)
  gui, man, authors: Update docs, translations, and contributors
  lib/config: Sanity checks on MaxConcurrentWrites (ref syncthing#7064) (syncthing#7069)
  lib/ur: Fix panics in failure-reporting (fixes syncthing#7090) (syncthing#7091)
  lib/ur: Fix panics in failure-reporting (fixes syncthing#7090) (syncthing#7091)
  build: Update dependencies (syncthing#7088)
  lib: Remove USE_BADGER experiment (syncthing#7089)
  build: Update notify (fixes syncthing#7063) (syncthing#7080)
  lib/api: Fix /rest/config path and add methods to cors (ref syncthing#7001) (syncthing#7081)
  lib/api: Allow OPTIONS method in CORS preflight request handling (ref syncthing#7017) (syncthing#7079)
  gui: Fix another undefined variable access (fixes syncthing#7077) (syncthing#7078)
  lib/config: Check for "msdos" when detecting FAT FS in Android (syncthing#7072)
  gui, man, authors: Update docs, translations, and contributors
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Nov 2, 2021
@syncthing syncthing locked and limited conversation to collaborators Nov 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants