Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

raphaelDL
Copy link
Contributor

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

@jzheaux jzheaux self-assigned this Dec 17, 2018
@jzheaux jzheaux added in: web An issue in web modules (web, webmvc) type: enhancement A general enhancement status: duplicate A duplicate of another issue labels Dec 17, 2018
Copy link
Contributor

@jzheaux jzheaux left a 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.

@raphaelDL raphaelDL force-pushed the gh-6259 branch 5 times, most recently from 5326f3c to 0080db0 Compare December 20, 2018 18:07
Copy link
Contributor

@jzheaux jzheaux left a 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}.
Copy link
Contributor

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.

Copy link
Contributor Author

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());
Copy link
Contributor

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)

Copy link
Contributor Author

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());
Copy link
Contributor

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")

Copy link
Contributor Author

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.
Copy link
Contributor

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.

* <p>
* In a servlet 3 environment {@link SecurityContextHolderAwareRequestWrapper} is extended
* to provide the following additional methods:
* {@link SecurityContextHolderAwareRequestWrapper} is extended to provide the following
Copy link
Contributor

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!

Copy link
Contributor Author

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:

@raphaelDL raphaelDL force-pushed the gh-6259 branch 3 times, most recently from 7d98083 to 12f412f Compare December 20, 2018 18:54
@raphaelDL
Copy link
Contributor Author

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
@jzheaux
Copy link
Contributor

jzheaux commented Dec 21, 2018

Okay, @raphaelDL, I'm just going to do a quick polish, and then we'll merge.

@jzheaux
Copy link
Contributor

jzheaux commented Dec 21, 2018

Thanks again, @raphaelDL! This is now merged into master via 086b105. Also, I did a quick polish on the unit tests and in one of the JavaDocs: 7a55af2

@jzheaux jzheaux closed this Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants