Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

bug: Strip padding from key content #452

Merged
merged 1 commit into from
Apr 28, 2016
Merged

bug: Strip padding from key content #452

merged 1 commit into from
Apr 28, 2016

Conversation

jrconlin
Copy link
Member

The client will soon reject any key content that includes padding.

The server will need to watch and strip it. We should also return a
warning message, however the likelihood of that warning being noticed
is minimal.

Closes #451

@bbangert, @kitcambridge r?

(Let the great debate ensue!)

@@ -395,6 +395,9 @@ class EndpointHandler(AutoendpointHandler):
"encryption-key", "content-type",
"authorization"]
cors_response_headers = ["location", "www-authenticate"]
# Remove trailing padding characters from complex header items like
# Crypto-Key and Encryption
strip_pad = re.compile("=+(?=[,;]|$)")
Copy link

@ghost ghost Apr 21, 2016

Choose a reason for hiding this comment

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

I think we'll want to account for the quote ([,;"]), too, in case they pass a quoted string. I don't think we really need to check that it's a valid quoted string, though. It might provide more helpful errors, and avoid routing/storing a message that we know is invalid. Your call.

@@ -395,6 +395,9 @@ class EndpointHandler(AutoendpointHandler):
"encryption-key", "content-type",
"authorization"]
cors_response_headers = ["location", "www-authenticate"]
# Remove trailing padding characters from complex header items like
# Crypto-Key and Encryption
strip_pad = re.compile('=+(?=[,;]|$)')
Copy link
Member

Choose a reason for hiding this comment

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

strip_padding? Shortening it there makes it sound... odd.

@bbangert
Copy link
Member

r+ pending minor nits. strip_pad is meh, but the other method of conditionally including the space should at least have a comment indicating why its doing such a list splice with a boolean eval back to a int.

@ghost
Copy link

ghost commented Apr 28, 2016

Thinking about this some more, I'm now wondering if we shouldn't do this.

Aurora 48 and Nightly 49 already reject padding, and we haven't seen breakage yet. The spec is also new enough to where we can discourage input like this, and Google will follow suit (they suggested prohibiting padding). Finally, we don't validate headers besides Crypto-Key; I could send Encryption: chocolate=yes, and the server would happily pass it through to the client.

But I could also see this being a common enough mistake. I'll leave the final judgement to you and @bbangert. 😸

@jrconlin
Copy link
Member Author

I view the padding issue as a needless annoyance to the developer. They already have several significant hurdles to overcome (encryption, user data management, scaling) and then us rejecting their submission because they included characters that literally signify nothing would certainly put me into a foul mood. It would be like having my thesis rejected because the staple was facing the wrong way. I can understand where being more pedantic would make sense if we had elements that required strict formatting (A somewhat legitimate example is the VAPID JWT header, where extra padding existing in the header or claims absolutely impacts the generated signature) but that case is not true for Crypto-Key or other fields.

Doing a simple, low cost action like ignoring extra padding makes lives slightly better. I'm ok with doing that.

The client will soon reject any key content that includes padding.
The server will need to watch and strip it. We should also return a
warning message, however the likelihood of that warning being noticed
is minimal.

Closes #451
@bbangert
Copy link
Member

r+

@bbangert bbangert merged commit c2ac073 into master Apr 28, 2016
@bbangert bbangert deleted the bug/nopad branch April 28, 2016 16:50
@ghost ghost mentioned this pull request Apr 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants