Open annevk opened 7 years ago
Chrome definitely leaks Last-Event-ID
as per the above description. I need a better tool to know whether Firefox or Safari does it as neither debugger shows much information.
Confirmed that Firefox and Safari do it though using Charles Proxy. We should just safelist the header.
@whatwg/security thoughts?
@johnwilander @horo-t I'm no longer convinced that safelisting this is correct as it would allow for the kind of values that might result in script execution on the server and they could potentially bypass the length checks we now have in place. Do you have thoughts on how to fix this?
Sorry, I'm not familiar with EventSource. @yutakahirano knows more than me.
@johnwilander @yutakahirano ping.
and they could potentially bypass the length checks we now have in place
Can you elaborate on this a bit more?
@yutakahirano create a same-origin server-sent events endpoint. Generate a very large ID and then end the stream. Upon seeing the very large ID, redirect to the victim server.
If we safelist last-event-id
, values larger than 128 octets will be rejected by https://fetch.spec.whatwg.org/#cors-safelisted-request-header. Do you think that's enough?
The other problem is that it can contain essentially any header value byte, which historically has been an attack vector (and is why we have restrictions on the other headers now).
We'd have to apply the same restrictions as with accept
.
Sounds good. Then what we need to do is to check how many site would be broken by such a change, right?
Yeah.
FWIW I think I can help such an investigation. I'm not sure I'll have enough time to ship the change in the near future because we'll need to talk with enterprise people to actually ship this kind of change.
FWIW I think I can help such an investigation. I'm not sure I'll have enough time to ship the change in the near future because we'll need to talk with enterprise people to actually ship this kind of change.
@yoichio is working on this.
Hi, I got a statistics. The Chrome UMA shows usage is 0.00020% and Blink API owner, or @yoavweiss said "the low usage suggests that the intent may not get a lot of pushback, assuming other browsers are planned to follow."
So I'd say the change looks safe in terms of compatibility risk.
That is great news! Here is what we need to do specification-wise:
last-event-id
right below accept
so it ends up sharing the same algorithm.I suspect that all implementers are on board aligning here given that it currently represents a hole in our same-origin policy protections.
cc @youennf @KershawChang
Is there any movement on this, or ways that I as a non-browser developer can help move this along? Some environments do not have a native EventSource implementation, and polyfilling these with a fetch implementation currently triggers CORS preflights when a last event ID is sent, which not all servers have safelisted.
None of the outlined steps involve browser engineering. It involves making a change to the standard defined in this repository and corresponding test changes in https://github.com/web-platform-tests/wpt. This is some work, but it should be relatively straightforward. If you get stuck somewhere feel free to reach out on https://whatwg.org/chat.
Per https://github.com/whatwg/html/issues/689 it can contain any header value. And it seems that a page with a cooperating server can send that header anywhere due to redirects.
Basically, use
EventSource
to open a connection. Get the server to set the ID. Then trigger a reconnection. Then when the server gets the header, redirect that request to wherever. That request to wherever will include theLast-Event-ID
header with a value that can be controlled by the server that did the redirect.Given that this has been the case for forever, we might as well enshrine it. (Should probably write a test to confirm though.)