Commit dd6982f
committed
A pair of CRITICAL security issues were identified by contributors:
1. Sente was leaking its CSRF token from its WebSocket handshake route.
And since in the common case, this is a shared token also used by the
rest of the application, this means that Sente was often in practice
leaking the application's CSRF token.
2. No CSRF protection was being provided for WebSocket handshakes.
This commit makes the following changes-
1. [BREAKING] The client-side :chsk/handshake event now always has `nil`
where it once provided the csrf-token provided by the server.
I.e. before: `[:chsk/handshake [<?uid> <csrf-token> <?handshake-data> <first-handshake?>]]
after: `[:chsk/handshake [<?uid> nil <?handshake-data> <first-handshake?>]]
2. [BREAKING] `make-channel-socket-client!` now takes an extra argment: an
explicit csrf-token. The value for the token should be extracted from the
page HTML (see example project).
3. CSRF *checks* are now performed by Sente directly, and don't depend on
an external route wrapper like `ring-anti-forgery`, etc.
4. CSRF checks now cover all Sente's internal endpoints, including Ajax
POSTs, long-polling requests, and WebSocket handshakes.
5. Sente will now by default fail to work without CSRF tokens properly
configured.
1 parent 51e8888 commit dd6982f
File tree
5 files changed
+131
-75
lines changed- example-project
- src/example
- src/taoensso
5 files changed
+131
-75
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| |||
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
| 52 | + | |
44 | 53 | | |
45 | 54 | | |
46 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
119 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
0 commit comments