Commit d008b9b
authored
Merge commit from fork
getSession() calls @auth/core, which returns a 500 with a JSON body of
{ message: "There was a problem with the server configuration..." } when
the provider configuration is invalid (e.g. a provider missing both
`issuer` and `authorization` endpoints). The next-auth wrappers read that
body with .json() without checking the response status, so the error object
was assigned to req.auth. Truthiness checks such as `!!auth` / `if (!req.auth)`
- the pattern shown in the docs - then evaluated as authenticated for every
request, failing open and exposing protected routes during a misconfiguration.
Parse the session response through a helper that returns null on any non-OK
response, so all auth() entry points (RSC, middleware inline/wrapper, API
routes) fail closed. Add a regression test reproducing the InvalidEndpoints
misconfiguration.
Fixes GHSA-8fpg-xm3f-6cx31 parent af42d8f commit d008b9b
2 files changed
Lines changed: 90 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
99 | 116 | | |
100 | 117 | | |
101 | 118 | | |
| |||
131 | 148 | | |
132 | 149 | | |
133 | 150 | | |
134 | | - | |
| 151 | + | |
135 | 152 | | |
136 | 153 | | |
137 | 154 | | |
| |||
168 | 185 | | |
169 | 186 | | |
170 | 187 | | |
171 | | - | |
| 188 | + | |
172 | 189 | | |
173 | 190 | | |
174 | 191 | | |
175 | 192 | | |
176 | 193 | | |
177 | 194 | | |
178 | | - | |
| 195 | + | |
179 | 196 | | |
180 | 197 | | |
181 | 198 | | |
| |||
184 | 201 | | |
185 | 202 | | |
186 | 203 | | |
187 | | - | |
| 204 | + | |
188 | 205 | | |
189 | 206 | | |
190 | 207 | | |
| |||
218 | 235 | | |
219 | 236 | | |
220 | 237 | | |
221 | | - | |
| 238 | + | |
222 | 239 | | |
223 | 240 | | |
224 | 241 | | |
225 | 242 | | |
226 | 243 | | |
227 | | - | |
| 244 | + | |
228 | 245 | | |
229 | 246 | | |
230 | 247 | | |
| |||
236 | 253 | | |
237 | 254 | | |
238 | 255 | | |
239 | | - | |
| 256 | + | |
240 | 257 | | |
241 | 258 | | |
242 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
0 commit comments