Commit 23ae687
committed
fix(security): use LOAD_LIBRARY_SEARCH_* safe flags in Windows loader
Replace LOAD_WITH_ALTERED_SEARCH_PATH (0x8) with
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | _USER_DIRS | _SYSTEM32. The old flag
sets the DLL's own directory as the first search path but leaves the
legacy unsafe search order (CWD, %PATH%) enabled for transitive
dependencies — a real DLL-hijack vector if libwebp.dll itself
depends on or is patched to depend on an attacker-droppable basename.
The new flag set restricts dependency resolution to the DLL's directory
plus System32 (and any user-added directories), explicitly excluding
CWD and %PATH%.
Fall back to LOAD_WITH_ALTERED_SEARCH_PATH on ERROR_INVALID_PARAMETER
(87) for pre-KB2533623 Windows, so we don't regress loading on very old
hosts. Only applies to !NETCOREAPP — .NET Core uses NativeLibrary.TryLoad
and the DllImportResolver in NativeLibraryBootstrap.1 parent aadad0c commit 23ae687
1 file changed
Lines changed: 30 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
494 | 506 | | |
495 | 507 | | |
496 | | - | |
497 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
498 | 526 | | |
499 | 527 | | |
500 | 528 | | |
| |||
0 commit comments