-
Notifications
You must be signed in to change notification settings - Fork 6k
Remove Servlet 2.5 Support for Session Fixation #6297
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
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.
Thanks, @raphaelDL! I've left some feedback inline.
...ringframework/security/web/authentication/session/ChangeSessionIdAuthenticationStrategy.java
Show resolved
Hide resolved
.../springframework/security/config/annotation/web/configurers/SessionManagementConfigurer.java
Show resolved
Hide resolved
...ramework/security/web/authentication/session/ChangeSessionIdAuthenticationStrategyTests.java
Show resolved
Hide resolved
5326f3c
to
0080db0
Compare
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.
Looking good, @raphaelDL. I've commented inline about a little more polish in the comments and the tests. We should be just about there.
@@ -24,8 +24,7 @@ | |||
import javax.servlet.http.HttpSession; | |||
|
|||
/** | |||
* The default implementation of {@link SessionAuthenticationStrategy} when using < | |||
* Servlet 3.1. | |||
* The default implementation of {@link SessionAuthenticationStrategy}. |
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.
So, this actually is not the default implementation. It's tricky because of the encoded less than, but it said "The default implementation is X when using < Servlet 3.1". Since we no longer support < Servlet 3.1, this won't be the default anymore.
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.
oh god, thanks
verifyStatic(ReflectionUtils.class); | ||
ReflectionUtils.invokeMethod(same(method), any(HttpServletRequest.class)); | ||
|
||
Assert.assertNotEquals(id, request.getSession().getId()); |
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.
Would you do me a favor and please use AssertJ instead? assertThat(request.getSession().getId()).isEqualTo(id)
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.
done
ReflectionUtils.invokeMethod(same(method), any(HttpServletRequest.class)); | ||
|
||
Assert.assertNotEquals(id, request.getSession().getId()); | ||
Assert.assertEquals(request.getParameter(token.getParameterName()), token.getToken()); |
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.
What are you wanting to verify by checking the request parameters? Since they aren't part of the session, they wouldn't be affected by session changes.
Not sure if this is what you are going for, but to confirm that session fixation didn't squash anything the session, we'd need to add a session attribute, e.g. request.getSession().setAttribute("custom", "value")
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.
that was the idea, I changed that
/** | ||
* Uses {@code HttpServletRequest.changeSessionId()} to protect against session fixation | ||
* attacks. This is the default implementation for Servlet 3.1+. | ||
* attacks. |
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.
This is now the default implementation.
web/src/main/java/org/springframework/security/web/servletapi/HttpServletRequestFactory.java
Outdated
Show resolved
Hide resolved
* <p> | ||
* In a servlet 3 environment {@link SecurityContextHolderAwareRequestWrapper} is extended | ||
* to provide the following additional methods: | ||
* {@link SecurityContextHolderAwareRequestWrapper} is extended to provide the following |
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.
There is a separate ticket for this class, so let's go ahead and leave these changes out in this file out. Thank you, though!
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.
on it, wait a second, messed up my branch D:
7d98083
to
12f412f
Compare
I'm working to fix the red build |
This commit removes existence validation of a method only available in Servlet 3.1. Spring Framework baseline is Servlet 3.1 so is not longer required. Fixes: spring-projectsgh-6259
Okay, @raphaelDL, I'm just going to do a quick polish, and then we'll merge. |
Thanks again, @raphaelDL! This is now merged into |
This commit removes existence validation of a method only available in Servlet 3.1.
Spring Framework baseline is Servlet 3.1 so is not longer required.
Fixes: gh-6259