Reject relative package URIs#1683
Merged
Merged
Conversation
bioball
requested changes
Jun 15, 2026
bioball
left a comment
Member
There was a problem hiding this comment.
Some nits, but also: can you add a test in pkl-core/src/test/files/LanguageSnippetTests/input/packages?
| var resolved = cacheDir.resolve(relativePath).normalize(); | ||
| if (!resolved.startsWith(cacheDir.normalize())) { | ||
| throw new SecurityException( | ||
| ErrorMessages.create("packageUriEscapesCacheDir", uri.getUri())); |
Member
There was a problem hiding this comment.
Can this ever happen? It's not possible to construct a PackageUri with path traversal segments now, right?
If not, we can just change this to:
assert resolved.startsWith(cacheDir.normalize());
Contributor
Author
There was a problem hiding this comment.
No, this shouldn't happen. But it's a second line of defense, so I think it's worth leaving it there.
Member
There was a problem hiding this comment.
Gotcha, makes sense. I think, in this case, we should turn this into a PklBugException, because this is a bug on our part.
bioball
approved these changes
Jun 16, 2026
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.
No description provided.