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
Fix RemoveRelativePathComponents (again) and fix mod security with paths starting with ".." #4919
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just this minor thing, 👍 otherwise
} | ||
if (pos > 0) { | ||
pos++; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brace removal possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code style nowhere mandates that braces should be removed. Both placing braces and not placing them is fine.
Does this replace #4849 ? If there's a conflict which should be merged first? |
@paramat No, those two PRs fix two seperate issues with mod security. |
This used to return "/foo" for "../foo" when it should return the enpty string (i.e., error removing all relative components).
Trying to resolve a path with RemoveRelativePathComponents that can't be resolved without leaving leading parent components (e.g. "../worlds/foo" or "bar/../../worlds/foo") will fail. To work around this, we leave the relative components and simply remove the trailing components one at a time, and bail out when we find a parent component. This will still fail for paths like "worlds/foo/noexist/../auth.txt" (the path before the last parent component must not exist), but this is fine since you won't be able to open a file with a path like that anyways (the O.S. will determine that the path doesn't exist. Try `cat /a/../etc/passwd`).
175f103
to
aee24c8
Compare
@sfan5: Done. |
Applying: Fix RemoveRelatvePathComponents When attempting to merge after #4849, so i will merge #4849 only for now. |
#4849 merged. |
Fixes #4909.
string (i.e., error removing all relative components). Also, "./foo" should be resolved to "foo".
cat /a/../etc/passwd
).