-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Issue #11271 - fix use of AliasCheckers with CombinedResource #11279
Issue #11271 - fix use of AliasCheckers with CombinedResource #11279
Conversation
Signed-off-by: Lachlan Roberts <[email protected]>
Signed-off-by: Lachlan Roberts <[email protected]>
Signed-off-by: Lachlan Roberts <[email protected]>
Signed-off-by: Lachlan Roberts <[email protected]>
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AllowedResourceAliasChecker.java
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <[email protected]>
.../jetty-server/src/main/java/org/eclipse/jetty/server/SymlinkAllowedResourceAliasChecker.java
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <[email protected]>
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AllowedResourceAliasChecker.java
Show resolved
Hide resolved
@@ -192,6 +206,26 @@ protected boolean isAllowed(Path path) | |||
return false; | |||
} | |||
|
|||
protected boolean isSameFile(Path path, Resource resource) |
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.
We could have isSameFile(Path)
as a method on Resource
, then only CombinedResource
would need the iteration.
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.
@lachlan-roberts bump
...ee10-test-integration/src/test/java/org/eclipse/jetty/ee10/test/AliasCheckerSymlinkTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <[email protected]>
…e behaviour Signed-off-by: Lachlan Roberts <[email protected]>
Signed-off-by: Lachlan Roberts <[email protected]>
@gregw with the change in behaviour to They are expecting a request for Are we ok with this behaviour change? if so I will just make these tests use the |
@lachlan-roberts there is a bit to unpack here. Firstly the redirect from Otherwise, I don't like behaviour changes.... but I think in this case it is really REALLY strange that by adding something to allows symlinks we are also allowing arbitrary aliasing within the docroot, possibly bypassing security checks etc. To me that was wrong behaviour in the first place, so I'm kind of OK with changing it. What is the additive behaviour of alias checkers? Does it just need to be approved by one? In which case the fix for anybody that complains is to add both symlinks and allowed alias checkers (does that fix the failing test?) However, I am still curious as to why there is a behaviour change? What was the previous checker doing that says |
@gregw AFAICT alias checking should take precedence over everything else. This is how they were designed, and it's what I think makes the most sense. So it feels like this (fortunately small) change of behavior is actually fixing something that used to be incorrect. |
@gregw yes it just needs to be approved by one, so adding
In the The |
We should not allow dir%2Findex.html just because we allow symlinks. This is exactly the kind of security constraint bypassing alias that the alias mechanism was implemented to protect against. |
Then we are going to have to rethink the design of our alias checkers. We never re-verify against the security constraints, only the protected targets. We even say in the javadoc:
We only base this on whether it is a file inside the base resource which is not a protected target. And for the symlink checker once we hit a symlink file which is an allowed resource we approve, regardless of what comes after that symlink. |
@lachlan why do we need a big rethink? If somebody adds the allowed file resource checker, then any alias is ok so long as it is in the docroot and not protected. If they add them symlink checker it should just allow Sym links and not arbitrary other aliases. The name says it! |
Well the name says
So right now if there is a symlink file which is an "allowed resource" as defined by the From what I understand you want the symlink alias checker to approve aliases if they are an alias only because of symlinks and nothing else. But to do this we would need to separate it from the logic of the |
@lachlan-roberts I don't understand why you want to combine allowed resources with symlink checking? If you want both then add both be alias checkers. What's wrong with the implementation as we last reviewed it together. Just remove that last conditional return true after checking for symlinks and it is ok. |
@gregw I'm not trying to combine them they already are. This is just how it is currently works. If you want to separate them then we're going to have to make some bigger changes to
This is already removed. That check was saying if it didn't contain a symlink we could approve it anyway if its an allowed resource. But now we're talking about the case where it does contain a symlink. |
Signed-off-by: Lachlan Roberts <[email protected]>
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/TrailingSlashAliasChecker.java
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <[email protected]>
failing due to unrelated flaky tests |
After re-running tests it is getting to an actual failure. It is failing after the changes we made to |
Signed-off-by: Lachlan Roberts <[email protected]>
Signed-off-by: Lachlan Roberts <[email protected]>
@gregw bump |
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.
Any idea why it is not passing CI?
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AllowedResourceAliasChecker.java
Show resolved
Hide resolved
@@ -192,6 +206,26 @@ protected boolean isAllowed(Path path) | |||
return false; | |||
} | |||
|
|||
protected boolean isSameFile(Path path, Resource resource) |
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.
@lachlan-roberts bump
…11271-AliasCheckCombinedResource
Signed-off-by: Lachlan Roberts <[email protected]>
@gregw the failures were flaky tests |
Issue #11271
Add support for CombinedResource in
AllowedResourceAliasChecker
andSymlinkAllowedResourceAliasChecker
.Also added more testing into
AliasCheckerSymlinkTest
.