Repository navigation
Commit e3f9c76
committed
fix: close symlink-listing, TOCTOU, and skip-count gaps in grep_file/list_files
Addresses 4 issues mesutoezdil found in review on PR #2267:
- ListDirContent listed a directory symlink (e.g. every session's "skills"
entry) as a file instead of a directory, since entry.IsDir() doesn't
follow symlinks. Now stats symlink entries to classify them correctly,
matching Python's existing symlink-following behavior.
- classifyWalkEntry verified a walked entry's resolved, in-bounds target,
but grepFile then reopened the original unresolved path -- a
verify-then-use gap where the symlink's target could differ between the
check and the read. grepFile now reads the resolved path that was
actually verified. This narrows the race but doesn't fully eliminate it
(documented in a comment on classifyWalkEntry); closing it completely
would need platform-specific work disproportionate to this file's
existing security bar.
- Go and Python both silently dropped the "N entries could not be read"
note whenever there were also real matches, only surfacing it when the
result was otherwise empty -- masking partial failures. Both now append
it alongside real matches too.
Verified end-to-end on a live kind cluster via A2A against redeployed
Go- and Python-runtime test agents, extracting raw tool function_response
payloads (not model-summarized text) to confirm each fix's actual
behavior, plus a targeted regression check confirming symlink-escape
protection still holds after the refactor.
Signed-off-by: brandonkeung <[email protected]>1 parent a56d813 commit e3f9c76
4 files changed
Lines changed: 161 additions & 17 deletions
File tree
- go/adk/pkg/skills
- python/packages/kagent-skills/src/kagent
- skills
- tests/unittests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
132 | 144 | | |
133 | 145 | | |
134 | 146 | | |
| |||
164 | 176 | | |
165 | 177 | | |
166 | 178 | | |
167 | | - | |
168 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
169 | 194 | | |
170 | | - | |
| 195 | + | |
171 | 196 | | |
172 | 197 | | |
173 | 198 | | |
174 | | - | |
| 199 | + | |
175 | 200 | | |
176 | 201 | | |
177 | 202 | | |
178 | | - | |
| 203 | + | |
179 | 204 | | |
180 | 205 | | |
181 | 206 | | |
182 | 207 | | |
183 | 208 | | |
184 | | - | |
| 209 | + | |
185 | 210 | | |
186 | 211 | | |
187 | 212 | | |
188 | 213 | | |
189 | 214 | | |
190 | | - | |
| 215 | + | |
191 | 216 | | |
192 | 217 | | |
193 | 218 | | |
194 | 219 | | |
195 | 220 | | |
196 | | - | |
| 221 | + | |
197 | 222 | | |
198 | | - | |
| 223 | + | |
199 | 224 | | |
200 | 225 | | |
201 | 226 | | |
| |||
216 | 241 | | |
217 | 242 | | |
218 | 243 | | |
| 244 | + | |
219 | 245 | | |
220 | 246 | | |
221 | 247 | | |
| |||
254 | 280 | | |
255 | 281 | | |
256 | 282 | | |
257 | | - | |
258 | 283 | | |
259 | 284 | | |
260 | 285 | | |
| |||
272 | 297 | | |
273 | 298 | | |
274 | 299 | | |
275 | | - | |
| 300 | + | |
276 | 301 | | |
277 | 302 | | |
278 | 303 | | |
279 | 304 | | |
280 | 305 | | |
281 | 306 | | |
282 | | - | |
| 307 | + | |
283 | 308 | | |
284 | 309 | | |
285 | 310 | | |
286 | 311 | | |
287 | 312 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | 313 | | |
292 | 314 | | |
293 | 315 | | |
| |||
299 | 321 | | |
300 | 322 | | |
301 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
302 | 327 | | |
303 | 328 | | |
304 | 329 | | |
305 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
306 | 335 | | |
307 | 336 | | |
308 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
348 | 368 | | |
349 | 369 | | |
350 | 370 | | |
| |||
437 | 457 | | |
438 | 458 | | |
439 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
440 | 489 | | |
441 | 490 | | |
442 | 491 | | |
| |||
635 | 684 | | |
636 | 685 | | |
637 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
638 | 727 | | |
639 | 728 | | |
640 | 729 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
261 | 264 | | |
262 | 265 | | |
263 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
522 | 545 | | |
523 | 546 | | |
524 | 547 | | |
| |||
0 commit comments