Commit 8cbb976
fix: validate session ID in Pi captureTranscript before writing
Pi's ParseHookEvent calls captureTranscript on agent_end, which builds
the destination path from the hook-supplied session ID and writes the
transcript — all before the lifecycle dispatcher validates the ID in
DispatchLifecycleEvent. A "../"-laden ID could thus write outside the
.entire/tmp/pi cache directory.
Validate the session ID at the top of captureTranscript (the choke point
where it becomes a path, covering both call sites); an unsafe ID returns
"" — the function's existing "no capture" signal — so dispatch behavior
is unchanged. Also corrects the gosec comment on the write that wrongly
claimed the ID was already validated.
Taint is the local Pi hook payload (same-privilege), so severity is low;
this is defense-in-depth consistent with the other hook hardening in this
branch. The sibling cacheSessionID writes a fixed filename, not an
ID-derived path, so it needs no guard.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: ddfd40f73b221 parent 0e4b26f commit 8cbb976
2 files changed
Lines changed: 46 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
289 | 299 | | |
290 | 300 | | |
291 | 301 | | |
| |||
300 | 310 | | |
301 | 311 | | |
302 | 312 | | |
303 | | - | |
| 313 | + | |
304 | 314 | | |
305 | 315 | | |
306 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
214 | 249 | | |
215 | 250 | | |
216 | 251 | | |
| |||
0 commit comments