Repository navigation
libraries: a bare name is never looked for in the working directory - #3100
Merged
Merged
Conversation
Owner
Author
|
Review: the fix works. On a Mac, a planted library in the working directory loads on main and is refused at this head. Windows keeps System32 and Fixed and pushed (dc35b23):
|
ashhart
marked this pull request as ready for review
November 17, 2026 15:19
An optional library is tried last by its file name alone. On macOS dlopen searches the working directory for such a name, and on Windows the default DLL search includes it, so a library planted where the server is started was loaded. On macOS a bare name is now resolved to full paths first: DYLD_LIBRARY_PATH's folders, then DYLD_FALLBACK_LIBRARY_PATH's or /usr/local/lib and /usr/lib. On Windows the process takes the working directory out of its DLL search before its first load, for a name and for what a DLL imports. PATH on Windows and the system loader's search on Linux are unchanged.
…3 fake opens its stand-ins through the loader type
ashhart
force-pushed
the
security/library-search
branch
from
November 17, 2026 18:02
55181bc to
2b27cef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Before: a library opened by bare name, such as
libMoltenVK.dylibornvcuda.dll, could load from the directory the server was started in. macOS'sdlopentries the working directory for a bare name, and so does the Windows default DLL search. A file planted in a folder someone runstensorfoldfrom then ran as the server. After: on macOS a bare name is tried only in the full-path folders ofDYLD_LIBRARY_PATH, then ofDYLD_FALLBACK_LIBRARY_PATH(default/usr/lib, dyld's own). On Windows the working directory leaves the DLL search before any library loads. Linux loaders never searched it.SECURITY.mdasks for private reports, so there is no public issue.main: the change, the review fixes, and a comment fix for the lean check.atc overlap --json: not run.Checks on this head
55181bca92e6c2c03755543c84e0359bf51492b9. The checks below ran on the first commit,ee17c11063a3. The review fixes (dc35b2376a19, described in the comment below) made the default folder/usr/libalone and fixed a macOS compile break infamilies/h3/cuda_runtime_fake.zigthat these checks did not cover. The last commit only joins two comments that had been split across lines, which the lean check refuses. On this head: lean 341 against main's 341, andzig build test-windows-port-host test-runtime-libraries-host test-h3-boundaries: 34/34 steps succeeded; 68/68 tests passed.python3 tools/zig/lean_check.py, on the base and on this head: 341 on the base, 341 on this head, 0 new.zig fmt --checkandgit diff --check: passzig build test-windows-port-host compile-http-limits-windows-host: 14/14 steps succeeded; 23/23 tests passedzig build native: 66/66 steps succeededzig build test-server-cpu: 5/5 steps succeeded; 1330/1337 tests passed (7 skipped)zig build check-native-cuda-host compile-flashnext-mtp-parity-host compile-glm-native-open: 11/11 steps succeededzig build -Dhip=true check-native-hip-host test-native-hip-host: 10/10 steps succeeded; 26/26 tests passedzig build test-picture-host test-runtime-libraries-host: 21/21 steps succeeded; 38/43 tests passed (5 skipped)zig build test-golden test-server-security test-pull-security: 76/76 steps succeeded; 39/39 tests passedzig build test-windows-port-hostrun afresh with an empty cache: 27/27 tests passed, against 25/25 on mainsys.zigalso compiles forx86_64-windows-gnu,x86_64-linux-gnuandaarch64-linux-muslsecurity: a bare library name is never tried in the working directory, only in full-path folderssecurity: the working directory is out of the DLL search before any name or path is loadedSetDllDirectoryWcall is covered by the fake loader's test and a cross-compile only.zig build testand every step that runs on a GPU were not run: this Mac's GPU was serving a model.Receipt
dlopen("libplanted.dylib")from a folder holding that file loads it, and main'sDynLib.openis that same call. On this head the engine'sDynLib.opendoes not load the file, and it does onceDYLD_FALLBACK_LIBRARY_PATHnames the folder by full path.Checklist
For a change that reaches inference:
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Not measured: no served run.Notes for the reviewer
DYLD_LIBRARY_PATHis skipped by this search. dyld itself may still honor one when it resolves a library's own dependencies. That is the operator's setting, not a planted file's.DYLD_FALLBACK_LIBRARY_PATH, or pass a full path where the setting takes one.SetDllDirectoryW(L""), made once before the first load. The existing restricted search for system libraries is unchanged.Suggested changelog line
macOS and Windows: a library named without a folder no longer loads from the directory the server was started in.