Validate artifact_id in FileSystemArtifactStore to prevent path traversal#6432
Merged
y0z merged 1 commit intooptuna:masterfrom Feb 12, 2026
Merged
Conversation
FileSystemArtifactStore against path traversalc58e153 to
a3b87c4
Compare
Member
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.
Motivation
Validation was missing for
artifact_idinFileSystemArtifactStore, which meant joined paths could potentially point outside the intended base directory. While our higher-level APIs use UUIDs, adding a check here ensures the storage remains robust regardless of how it's called. I think it's better to enforce this at the storage level rather than relying on upstream callers.Description of the changes
A new
_get_filepathhelper handles the path construction and boundary checks. If someone tries to pass an absolute path or something with..as an ID, the code now throws aValueError. All file operations in the class now use this helper, and I also added a test case intests/artifacts_tests/test_filesystem.pyto verify it works as expected.