Commit f78a575
committed
fix(security): do not allow all origins by default
BREAKING CHANGE: previously, all origins were allowed by default, which
meant that a Socket.IO server sent the necessary CORS headers
(`Access-Control-Allow-xxx`) to any domain by default.
Please note that you are not impacted if:
- you are using Socket.IO v2 and the `origins` option to restrict the list of allowed domains
- you are using Socket.IO v3 (disabled by default)
This commit also removes the support for '*' matchers and protocol-less
URL:
```
io.origins('https://example.com:443'); => io.origins(['https://example.com']);
io.origins('localhost:3000'); => io.origins(['http://localhost:3000']);
io.origins('http://localhost:*'); => io.origins(['http://localhost:3000']);
io.origins('*:3000'); => io.origins(['http://localhost:3000']);
```
To restore the previous behavior (please use with caution):
```js
io.origins((_, callback) => {
callback(null, true);
});
```
See also:
- https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
- https://socket.io/docs/v3/handling-cors/
- https://socket.io/docs/v3/migrating-from-2-x-to-3-0/#CORS-handling
Thanks a lot to https://github.com/ni8walk3r for the security report.1 parent d33a619 commit f78a575
2 files changed
+23
-47
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | | - | |
73 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
74 | 75 | | |
75 | | - | |
76 | | - | |
77 | 76 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
93 | 81 | | |
94 | | - | |
95 | 82 | | |
96 | 83 | | |
97 | 84 | | |
| |||
237 | 224 | | |
238 | 225 | | |
239 | 226 | | |
240 | | - | |
| 227 | + | |
241 | 228 | | |
242 | 229 | | |
243 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | 265 | | |
277 | 266 | | |
278 | 267 | | |
| |||
307 | 296 | | |
308 | 297 | | |
309 | 298 | | |
310 | | - | |
| 299 | + | |
311 | 300 | | |
312 | 301 | | |
313 | 302 | | |
| |||
320 | 309 | | |
321 | 310 | | |
322 | 311 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | 312 | | |
335 | 313 | | |
336 | 314 | | |
| |||
367 | 345 | | |
368 | 346 | | |
369 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
370 | 359 | | |
371 | 360 | | |
372 | 361 | | |
| |||
0 commit comments