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

Fix #9468 Space in Cookie name #9471

Merged
merged 5 commits into from
Mar 8, 2023

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Mar 7, 2023

Added a violation to allow unquoted spaces in cookie values to fix #9468

Added a violation to allow unquoted spaces in cookie values

Signed-off-by: gregw <gregw@webtide.com>
Added a violation to allow unquoted spaces in cookie values

Signed-off-by: gregw <gregw@webtide.com>
Copy link
Contributor

@joakime joakime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more test case please.

@@ -74,6 +74,8 @@ public static Stream<Arguments> data()
Arguments.of("abc= \"x\" ", "abc", "x"),
Arguments.of("abc= \"x\" ;", "abc", "x"),
Arguments.of("abc= \"x\" ; ", "abc", "x"),
Arguments.of("abc = x y z ", "abc", "x y z"),
Arguments.of("abc = x y z ", "abc", "x y z"),
Copy link
Contributor

@joakime joakime Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case that also uses a value with token separators (in this case a : colon)?

Arguments.of("abc=a:x b:y c:z", "abc", "a:x b:y c:z")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if the input was abc=a;x b;y c;z as well? (semi-colon)

Signed-off-by: gregw <gregw@webtide.com>
@gregw gregw requested a review from joakime March 7, 2023 19:51
/**
* Allow spaces within values without quotes.
*/
SPACE_IN_VALUES("https://www.rfc-editor.org/rfc/rfc6265#section-5.2", "Space in value");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to singular, SPACE_IN_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.

@sbordet Most of the violations are in the plural. It is more natural to say you allow the plural than to allow the singular.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe should be SPACES_IN_VALUES?

{
spaces++;
}
else if (c == ';' || c == ',' || c == '\t')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of the comment above, I don't think we can treat \t as a separator between cookies, can we?!?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't. This just changes state to END, which can accept a tab as optional white space around a value, but not as a separator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow. If we encounter \t the value ends, so it is a terminator char for the value, hence a separator between cookies, like the other chars in the if statement.

\t is a control char, so it's forbidden in every RFC, isn't it?
Why do we treat it specially? Historical reasons?

Signed-off-by: gregw <gregw@webtide.com>
Signed-off-by: gregw <gregw@webtide.com>
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a glitch on how \t is treated specially (which is orthogonal to this issue, but it has highlighted this special treatment), otherwise LGTM.

{
spaces++;
}
else if (c == ';' || c == ',' || c == '\t')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow. If we encounter \t the value ends, so it is a terminator char for the value, hence a separator between cookies, like the other chars in the if statement.

\t is a control char, so it's forbidden in every RFC, isn't it?
Why do we treat it specially? Historical reasons?

@gregw gregw merged commit 659f16d into jetty-10.0.x Mar 8, 2023
@gregw gregw deleted the jetty-10.0.x-9468-space-in-cookie-value branch March 8, 2023 20:07
@gregw
Copy link
Contributor Author

gregw commented Mar 9, 2023

@sbordet tab is treated specially as we have a violation that allows optional white space before/after a value. RFC6265 defines OWS in terms of WSP, which in RFC5234 is space or tab. Hence when we extended where OWS could be in the violation, we also included tab.

In this PR, we are allowing a space to be in the value, which is different to OWS, hence the decision to not include tab.

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.

Jetty 11.0.14 is less tolerant of non-compliant cookies than 11.0.13
3 participants