Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent path injection using ".." in object URLs #17

Merged
merged 2 commits into from
Nov 27, 2023

Conversation

lolepezy
Copy link
Contributor

No description provided.

@lolepezy
Copy link
Contributor Author

I am not sure what is a better way to go around the

path.toFile().getCanonicalFile().toPath());

It looks quite ugly, but path.toRealPath and path.toAbsolutePath do not have the same effect.

@bjpbakker
Copy link
Member

I am not sure what is a better way to go around the

path.toFile().getCanonicalFile().toPath());

It looks quite ugly, but path.toRealPath and path.toAbsolutePath do not have the same effect.

Probably the better way is to just normalize the paths. toRealPath has side effects by looking up actual FS paths, which is unwanted in these filters.

@ties
Copy link
Member

ties commented Nov 27, 2023

I am not sure what is a better way to go around the

path.toFile().getCanonicalFile().toPath());

It looks quite ugly, but path.toRealPath and path.toAbsolutePath do not have the same effect.

Probably the better way is to just normalize the paths. toRealPath has side effects by looking up actual FS paths, which is unwanted in these filters.

From a quick google query, Path.normalize + Path.startsWith seem to be the way to go.

@lolepezy lolepezy merged commit 8b564f0 into main Nov 27, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants