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

Cookie parsing does not adhere to RFC (concerning multiple values with the same key) #115

Open
tbu- opened this issue Jul 27, 2022 · 0 comments

Comments

@tbu-
Copy link

tbu- commented Jul 27, 2022

According to to the quoted RFC 6265, section 4.2.2

Although cookies are serialized linearly in the Cookie header,
servers SHOULD NOT rely upon the serialization order. In particular,
if the Cookie header contains two cookies with the same name (e.g.,
that were set with different Path or Domain attributes), servers
SHOULD NOT rely upon the order in which these cookies appear in the
header.

The relevant function Cookie::get does not comply with that:

pub fn get(&self, name: &str) -> Option<&str> {
self.iter()
.find(|&(key, _)| key == name)
.map(|(_, val)| val)
}

Instead, it only takes the first cookie value of a certain name.

The documentation should call this out, especially if this is not a de-facto standard somewhere because then it can create security vulnerabilities with different parts of a web stack taking different (first, last) values of a cookie with a certain name as authoritative.

@tbu- tbu- changed the title Cookie parsing does not adhere to RFC Cookie parsing does not adhere to RFC (concerning multiple values with the same key) Jul 27, 2022
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

No branches or pull requests

1 participant