Commit 95c1dce
Fix GHSA-873f-pvrv-4x83: warn before executing a bundle's config
monai.bundle.load(), with its default model=None, builds a bundle's
network by parsing the bundle's own config through create_workflow().
That parsing resolves any "_target_" value to an importable callable
with no allow list, and passes any "$"-prefixed value to Python
eval(). monai.bundle.run() reaches the same path via a caller-supplied
config_file. Either way, loading or running a bundle whose config
hasn't been reviewed can execute arbitrary code.
create_workflow() -- the shared path both load() and run() use to
parse a config file -- now raises a UserWarning immediately before
doing so, describing what "_target_"/"$"-expression content can do
and linking the advisory. This applies uniformly to every caller of
create_workflow(), not just load(). No behavior is blocked: the config
is still parsed and executed exactly as before, just with a warning
first. An earlier version of this fix added an opt-in
trust_remote_code flag to load(), but that was dropped after review:
MONAI has no way to establish whether a bundle is actually
trustworthy, so a flag like that would only teach callers to set it
once and forget about it.
Update docstrings on load(), run(), and create_workflow() to describe
the risk and point at the advisory.
Add TestLoadWarnsOnConfigExecution to tests/bundle/test_bundle_download.py:
default load() warns and still executes the config, explicit model=
skips config parsing entirely and warns about nothing, and run() warns
via the same create_workflow() path.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>1 parent 87060c4 commit 95c1dce
2 files changed
Lines changed: 93 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
651 | 659 | | |
652 | 660 | | |
653 | 661 | | |
| |||
935 | 943 | | |
936 | 944 | | |
937 | 945 | | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
938 | 952 | | |
939 | 953 | | |
940 | 954 | | |
| |||
1929 | 1943 | | |
1930 | 1944 | | |
1931 | 1945 | | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
1932 | 1952 | | |
1933 | 1953 | | |
1934 | 1954 | | |
| |||
1966 | 1986 | | |
1967 | 1987 | | |
1968 | 1988 | | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
1969 | 1996 | | |
1970 | 1997 | | |
1971 | 1998 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
372 | 378 | | |
373 | 379 | | |
374 | 380 | | |
| |||
477 | 483 | | |
478 | 484 | | |
479 | 485 | | |
480 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
481 | 491 | | |
482 | 492 | | |
483 | 493 | | |
| |||
488 | 498 | | |
489 | 499 | | |
490 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
491 | 554 | | |
492 | 555 | | |
0 commit comments