Repository navigation
Don't load the native library from a directory another user controls - #98
Merged
Merged
Conversation
lrytz
force-pushed
the
pr/native-loader-private-dir
branch
from
October 28, 2026 10:57
8ac5f54 to
37223d8
Compare
eed3si9n
reviewed
Oct 28, 2026
Comment on lines
+79
to
+82
| if ((isPrivateDirectory(parent) || isSharedStickyDirectory(parent)) | ||
| && isPrivateDirectory(dir)) { | ||
| return dir; | ||
| } |
Member
There was a problem hiding this comment.
I get the concern, but given that sbt is actively setting the sbt.ipcsocket.tmpdir property, adding a new check here may make the future debugging more confusing. Since we have control of the both repos, I suggest fixing this in sbt and runtimeDir() by moving the isPrivateDirectory checks there.
Contributor
Author
There was a problem hiding this comment.
OK, thanks. I dropped the second commit and moved the check into runtimeDir(), so it only covers the default directory. A directory set with sbt.ipcsocket.tmpdir is used as given.
The native library is extracted to a temporary directory and loaded from there. Without XDG_RUNTIME_DIR (common in cron jobs, containers and CI), that directory is in /tmp, with a name derived from the home directory: predictable, in a directory every user can write to, and used without checking who created it. Another user on the same machine could create it first and replace the library before it is loaded, and so run their code in the victim's process. Now the directory is only used if it belongs to the current user and no one else can write to it, and new directories are created private. Otherwise the library is extracted to a new private temporary directory. macOS and Windows are not affected, because their temporary directories are per user. A directory set with the sbt.ipcsocket.tmpdir property is used as given; whoever sets it is responsible for making it private. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lrytz
force-pushed
the
pr/native-loader-private-dir
branch
from
October 29, 2026 09:14
37223d8 to
5ffbc65
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.
The native library is extracted to a temporary directory and loaded from there. Without
XDG_RUNTIME_DIR(common in cron jobs, containers and CI), that directory is in/tmp, with a name derived from the home directory: predictable, in a directory every user can write to, and used without checking who created it. Another user on the same machine could create it first and replace the library before it is loaded, and so run their code in the victim's process.Now the directory is only used if it belongs to the current user and no one else can write to it, and new directories are created private. Otherwise the library is extracted to a new private temporary directory. macOS and Windows are not affected, because their temporary directories are per user. A directory set with the
sbt.ipcsocket.tmpdirproperty is used as given; whoever sets it is responsible for making it private.