Fork me on GitHub
#web-security
<
2022-10-18
>
orestis06:10:56

I saw an OPTIONS request in our logs recently, which is very confusing to me since we don't use cross-origin requests anywhere. We got alerted to it because Sentry caught the resulting error (an XHR status of 0)

seancorfield06:10:37

I would expect OPTIONS requests for any API that might be accessible via XHR in a UI.

orestis06:10:11

Even in the same origin? e.g. http://site.com/foo making an XHR/JSON request to http://site.com/api ?

seancorfield06:10:33

It wouldn't surprise me. It's up to the browser, yes?

seancorfield06:10:49

I don't associate that with cross-site requests.

seancorfield06:10:42

I mean, you may be right, but it's just not something I'd ever assumed would be only for cross-site requests...

orestis06:10:33

Getting hold of a spec of how this works is proving impossible, I’m getting drowned in a million tutorials.

seancorfield06:10:01

Yeah... a brief search does suggest that OPTIONS should only be sent if the request is to a different domain. Interesting. Although folks say it's browser-dependent and hard to control so I guess it's possible an aggressive browser is sending OPTIONS even when it doesn't strictly need to? What does the REFERER say in the logs, or don't you log that?

seancorfield06:10:33

(I had just assumed that XHR requests from JS would send OPTIONS even to the same domain but I'm less convinced now)

orestis06:10:57

No referer in the logs for OPTION request, I see if for other requests though.

orestis06:10:50

All the OPTIONS requests I see in our nginx access logs look to be bots/spam.

orestis07:10:36

Now I've gotten curious, I'll try to get to the bottom of this.

orestis08:10:49

Installing an HTTP interceptor, under normal circumstances, I don't see OPTIONS requests coming out of Chrome (chrome doesn't show the OPTIONS requests in the Network tab, so you have to look from the outside).

orestis08:10:09

In addition, that OPTIONS requested ended up in a "login required" redirect so I think someone was trying something fishy there.

seancorfield15:10:51

I'm surprised Chrome doesn't show those. Edge does and it's based on Chromium.

Dave Russell21:10:56

We’ve hit this before — I believe OPTION pre-flight requests are generally issued for “https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests” requests, even to the same domain. So many headers, HTTP methods, content-types, etc will cause the browser to issue a pre-flight.

Dave Russell21:10:09

As for the redirect to the login form, OPTION requests are often not authenticated (I can’t recall whether the browser sends cookies with them, but the expectation in CORS is that they don’t require auth), so it might be being caught in your generic middleware’s

Dave Russell21:10:50

Not saying someone isn’t doing something fishy, but if you don’t support CORS then an unauthenticated OPTION getting slammed with a 403 by the auth layer seems like a reasonable outcome 😛

orestis07:10:30

I expected I would see this much more often though. As it stands we're talking a single data point of an OPTIONS request to our /graphql endpoint for a single tenant - if it was hammered it would definitely show up in the logs. I don't believe same-domain requests (using XHR, not sure about the fancy new fetch api) get pre-flighted at any point.