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

Errata fix #2991

Merged
merged 7 commits into from
Feb 14, 2025
Merged

Errata fix #2991

merged 7 commits into from
Feb 14, 2025

Conversation

sbingler
Copy link
Collaborator

@sbingler sbingler commented Feb 3, 2025

Fixes erratum 6093

Comment on lines 352 to 356
Origin servers SHOULD NOT combine multiple Set-Cookie header fields into a
single header field. The usual mechanism for combining HTTP headers fields
(i.e., as defined in {{Section 5.3 of RFC9110}}) might change the semantics of
the Set-Cookie header field because the %x2C (",") character is used by
Set-Cookie in a way that conflicts with such combining.
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that the change is editorial, but it seems to me if you are concerned about combining by intermediaries, this is the opposite of the advice that you should be giving.

Copy link
Member

Choose a reason for hiding this comment

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

  1. We're changing this to a MUST in [RFC6265bis] Harden requirements for the Set-Cookie profile. #2988. Perhaps changing the wording in that PR would be simpler than rebasing this on top of that?

  2. I'm not sure I follow your suggestion, @martinthomson. What advice should we be giving here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps changing the wording in that PR would be simpler than rebasing this on top of that?

Now that it's just a single change in this PR I think combining them is just as easy as not (maybe easier to avoid merge issues)

I'm not sure I follow your suggestion, @martinthomson. What advice should we be giving here?

I'm also not clear on why this isn't the correct advice.

Copy link
Contributor

@martinthomson martinthomson Feb 6, 2025

Choose a reason for hiding this comment

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

The statement says that you should not produce set-cookie: a=b;c=d from set-cookie: a=b and set-cookie: c=d. It justifies that by saying that the usual combining rules for fields don't work. However, the advice you want is: if you combine set-cookie, use a semicolon rather than a comma.

The thing that got me to react here was the implication that leaving the cookie fields alone carries a risk that an intermediary might combine fields without knowing that set-cookie is special. In THAT case, combining (using ";") at the origin server would be an excellent idea because it would avoid that happening.

(There are other concerns, like the effect of combining on HTTP/2 and HTTP/3 header compression efficiency. But maybe we don't need to get into that level of detail.)

It's possible that this is just poor wording. Maybe if you say that implementations (origin servers, any servers, intermediaries, clients, anyone) shouldMUST not combine set-cookie using ",". That this specifically names origin servers invokes all of the above questions. (If you agree, we should open an issue to clarify, rather than continuing here, where it will definitely be lost.)

Copy link
Collaborator Author

@sbingler sbingler Feb 11, 2025

Choose a reason for hiding this comment

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

However, the advice you want is: if you combine set-cookie, use a semicolon rather than a comma.

We don't want to give that advice either.
Within a set-cookie string any values separated by a semicolon will be treated as attributes for the first name=value pair.

From Section 5.6

  1. If the set-cookie-string contains a %x3B (";") character:
      1. The name-value-pair string consists of the characters up to, but not including, the first %x3B (";"), and the unparsed-attributes consist of the remainder of the set-cookie-string (including the %x3B (";") in question).

So set-cookie: a=b;c=d would set a cookie a=b with some attribute c that has a value of d. Since c is an unrecognized attribute it'll be ignored and a default a=b cookie will be set.

The thing that got me to react here was the implication that leaving the cookie fields alone carries a risk that an intermediary might combine fields without knowing that set-cookie is special.

Presumably an intermediary would have implemented the HTTP spec which specifically calls out Set-Cookie as special. Granted that's specified with an "ought".

That this specifically names origin servers invokes all of the above questions

Fair.

I think we can resolve this ambiguity by calling out origin servers and intermediaries. Something like

Origin servers and intermediaries MUST NOT each combine multiple Set-Cookie header fields into a...
Not sure how clear the "MUST NOT each" phrasing is, open to suggestions. This should take care of that ambiguity.

I'll upload a patch

@sbingler
Copy link
Collaborator Author

sbingler commented Feb 13, 2025

@mikewest Thoughts on the recent change?

Copy link
Member

@mikewest mikewest left a comment

Choose a reason for hiding this comment

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

This LGTM, but I think we could add a little more clarification of the problem since I'm not sure we're on the same page about that.

@sbingler sbingler merged commit f11fcdf into httpwg:main Feb 14, 2025
1 check passed
@sbingler sbingler deleted the ErrataFix branch February 14, 2025 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants