Repository navigation
Commit 382620c
authored
don't resolve the kernel's own connection file through the cwd (#1576)
init_connection_file makes up kernel-<pid>.json when no connection file
was passed on the command line, then hands that invented name to
filefind over the current directory and connection_dir, so a file of
that name sitting in the kernel's working directory wins and
load_connection_file adopts what is in it, HMAC key and all five ports
included. The launches that reach this are the ones without -f: ipython
kernel, python -m ipykernel_launcher on its own, and every embed_kernel
caller, and their working directory is frequently a checked-out project
or a shared directory nobody vetted. Whoever wrote that file then holds
the key the kernel signs and verifies with, which is all of the message
authentication there is, so they can hand it an execute_request. I
noticed it while following where the connection file actually gets
created and saw that the create branch is the fallback rather than the
default. Planting the file in a temp directory and calling
init_connection_file confirmed it, session.key came back as the planted
string and shell_port as the planted 51111. get_connection_file repeats
the same cwd-first lookup, so even once the kernel owns its file in
connection_dir, %connect_info and connect_qtconsole resolve the planted
basename ahead of the real one and hand that out instead. The fix
creates the file straight away when the name was ours to invent instead
of looking it up, and puts connection_dir ahead of the working directory
in get_connection_file; an explicit relative -f still resolves against
the working directory the way it always did, with a regression beside
the existing connection file tests in tests/test_kernelapp.py.3 files changed
Lines changed: 43 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
334 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
335 | 341 | | |
336 | 342 | | |
337 | 343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
0 commit comments