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

Wrapping problematic fields for signatures #2189

Merged
merged 3 commits into from
Jul 6, 2022
Merged

Wrapping problematic fields for signatures #2189

merged 3 commits into from
Jul 6, 2022

Conversation

jricher
Copy link
Contributor

@jricher jricher commented Jun 30, 2022

This adds a binary wrapper for fields that don't follow the List or Dictionary format for multiple values, such as Set-Cookie. The wrapper is selected
using the bs parameter, and the component value is made by wrapping each individual field value in a Byte Sequence and putting them into a List, then
doing a strict serialization on those values.

Closes #2166

@yaronf
Copy link
Contributor

yaronf commented Jul 1, 2022

In general, is this even needed or are we over-engineering here? If the main use case is Set-Cookie, do we think it is likely to be signed?


### Binary-wrapped HTTP Fields {#http-header-byte-sequence}

If the value of the the HTTP field in question is known by the application to cause problems with serialization, particularly with combination of multiple values as discussed in {{security-non-list}}, the signer MAY include the `bs` parameter in a component identifier to indicate the values of the fields need to be wrapped as binary structures before being combined.
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 not a MAY, it's at least a SHOULD because not using it would result in a security issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually fine with this being a SHOULD for the reasons given.

Suggested change
If the value of the the HTTP field in question is known by the application to cause problems with serialization, particularly with combination of multiple values as discussed in {{security-non-list}}, the signer MAY include the `bs` parameter in a component identifier to indicate the values of the fields need to be wrapped as binary structures before being combined.
If the value of the the HTTP field in question is known by the application to cause problems with serialization, particularly with combination of multiple values as discussed in {{security-non-list}}, the signer SHOULD include the `bs` parameter in a component identifier to indicate the values of the fields need to be wrapped as binary structures before being combined.


### Binary-wrapped HTTP Fields {#http-header-byte-sequence}

If the value of the the HTTP field in question is known by the application to cause problems with serialization, particularly with combination of multiple values as discussed in {{security-non-list}}, the signer MAY include the `bs` parameter in a component identifier to indicate the values of the fields need to be wrapped as binary structures before being combined.
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are aware of other common fields that need to be handled this way, let's list them in {{security-non-list}} as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Set-Cookie is the only common one that I found that fits this, but I didn't want the language to preclude other weirdness out there.

1. For each field value in the set:
0. Strip leading and trailing whitespace from each item in the list. Note that since HTTP field values are not allowed to contain leading and trailing whitespace, this will be a no-op in a compliant implementation.
1. Remove any obsolete line-folding within the line and replace it with a single space (" "), as discussed in {{Section 5.2 of HTTP1}}. Note that this behavior is specific to {{HTTP1}} and does not apply to other versions of the HTTP specification.
2. Encode the string as a Byte Sequence
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this mean? Maybe: encode the list as a structured field Byte Sequence using the list's ASCII representation. (This assumes that only ASCII is allowed, but that's really part of the problem.)

Copy link
Contributor Author

@jricher jricher Jul 1, 2022

Choose a reason for hiding this comment

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

@mnot is this an accurate way to say "take the header value as a binary"? To create the examples I encoded the strings, and field values are already a subset of ASCII characters allowed.

Suggested change
2. Encode the string as a Byte Sequence
2. Encode the resulting field value's ASCII representation as a Byte Sequence

@jricher jricher merged commit ce77f7c into main Jul 6, 2022
@jricher jricher deleted the wrapped-fields branch July 6, 2022 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Wrapped encoding for problematic fields
2 participants