Subject: Re: [OAUTH-WG] HTTP request signing and repeated query/header keys

From: Justin Richer <[email-masked]>
Date: Tue, 1 Mar 2016 14:02:26 -0800

+1, this was a driving requirement when I wrote the first strawman. I can’t tell you the number of times I had frameworks mess things up with OAuth 1, which does exactly the algorithm that you mention below. 

I’m currently in favor of just leaving the repeated parameter and header out of the core hashing mechanism. We could, if someone wanted to get really clever, introduce a more generic hashing mechanism that could handle the whole message in different ways. But I think the existing mechanism is good enough for most cases that we can roll with it.

 — Justin

> On Feb 28, 2016, at 7:18 PM, Phil Hunt (IDM) <[email-masked]> wrote:
> 
> The issue for any service is that things like gateways and proxies may change or add parameters.
> 
> There is a long tradition with http to mess with things headers and payload in the real world. Not ideal, but a certain reality. 
> 
> Thus for certain services it is likely only possible to sign a subset of params that the client and service provider want to verify did not change. 
> 
> Phil
> 
> On Feb 28, 2016, at 18:39, Manger, James <[email-masked] <mailto:[email-masked]>> wrote:
> 
>> Being able to selectively include or exclude individual query string name=value parameters in a signature feels far too dangerous. Always sign them all — with the only exception being the signature itself if transmitted as a query string parameter.
>> Unfortunately we do need to selectively include or exclude HTTP headers as they are a mix of transport, app-layer, end-to-end, and hop-by-hop items.
>>  
>> Ignoring duplicate query parameter names is a poor design for a fairly generic HTTP signing method. My suggestion would be to do a stable sort on parameter names. That is, sort the names, but preserve the order of values when a name appears multiple times. …hoping that works with almost all frameworks.
>>  
>> --
>> James Manger
>>  
>> From: OAuth [mailto:[email-masked] <mailto:[email-masked]>] On Behalf Of Brock Allen
>> Sent: Monday, 29 February 2016 12:17 PM
>> To: 'Justin Richer' <[email-masked] <mailto:[email-masked]>>
>> Cc: '<[email-masked] <mailto:[email-masked]>>' <[email-masked] <mailto:[email-masked]>>
>> Subject: Re: [OAUTH-WG] HTTP request signing and repeated query/header keys
>>  
>> Yea, I’m cool with just saying “duplicate keys won’t work” for my implementation, unless I do some implementation specific thing like sort them by value order or some such (but that would have to be on both sides).
>>  
>> -Brock
>>  
>> From: Justin Richer [mailto:[email-masked] <mailto:[email-masked]>] 
>> Sent: Sunday, February 28, 2016 8:13 PM
>> To: Brock Allen <[email-masked] <mailto:[email-masked]>>
>> Cc: <[email-masked] <mailto:[email-masked]>> <[email-masked] <mailto:[email-masked]>>
>> Subject: Re: [OAUTH-WG] HTTP request signing and repeated query/header keys
>>  
>> Yeah, that’s the trick — you don’t want to end up replicating the entire HTTP message inside the JWS envelope, because then you end up with a SOAP kind of approach where you’re not really using the outside HTTP constructs to their fullest anymore. 
>>  
>> In the end, I don’t think this spec is ever going to be perfectly universal, but if it can hit a majority of use cases with a simple and robust solution, I think we’re in good shape.
>>  
>>  — Justin
>>  
>> On Feb 28, 2016, at 1:50 PM, Brock Allen <[email-masked] <mailto:[email-masked]>> wrote:
>>  
>> Now that I’m thinking about this, the only thing that comes to mind is a hash of the value included somehow (which I’m sure you’ve already thought of). That’s obviously more complexity and overhead for all scenarios to support this edge case.
>>  
>> -Brock
>>  
>> From: Brock Allen [mailto:[email-masked] <mailto:[email-masked]>] 
>> Sent: Sunday, February 28, 2016 4:40 PM
>> To: 'Justin Richer' <[email-masked] <mailto:[email-masked]>>
>> Cc: '<[email-masked] <mailto:[email-masked]>>' <[email-masked] <mailto:[email-masked]>>
>> Subject: RE: [OAUTH-WG] HTTP request signing and repeated query/header keys
>>  
>> Ok, missed that – thanks.
>>  
>> For now in my implementation I’m also ignoring this problem :)
>>  
>> -Brock
>>  
>> From: Justin Richer [mailto:[email-masked] <mailto:[email-masked]>] 
>> Sent: Sunday, February 28, 2016 4:37 PM
>> To: Brock Allen <[email-masked] <mailto:[email-masked]>>
>> Cc: <[email-masked] <mailto:[email-masked]>> <[email-masked] <mailto:[email-masked]>>
>> Subject: Re: [OAUTH-WG] HTTP request signing and repeated query/header keys
>>  
>> In §7.5 we currently have:
>>  
>>    The behavior of repeated query parameters or repeated HTTP headers is
>>    undefined by this specification.  If a header or query parameter is
>>    repeated on either the outgoing request from the client or the
>>    incoming request to the protected resource, that query parameter or
>>    header name MUST NOT be covered by the hash and signature. [[ Note to
>>    the WG: is this something we need to cover? ]]
>>  
>> Which is to say: Yeah, that’s a problem, probably. We either declare this behavior out of scope and say you can’t use this method with that kind of API (or at least those parameters/headers) or we define a mechanism for handling that. I’m in favor of the former, and removing the text from the generation sections that says repeated parameters are processed with no special handling, making them explicitly out of scope throughout.
>>  
>> I would love to see more feedback from the group about this, especially if someone’s got a clever solution.
>>  
>>  — Justin
>>  
>> On Feb 28, 2016, at 1:31 PM, Brock Allen <[email-masked] <mailto:[email-masked]>> wrote:
>>  
>> Given that the client can iterate over the query/headers in any order to generate the concatenated value to hash, I think there’s an issue with query string or header values with repeated keys. I’ll stick with query params for simplicity in my sample.
>>  
>> If a client signs this concatenated query: “a=1&a=2” then the “p” value in the signed JSON object could be this:
>>  
>> "p": [["a", "a"], "blah"]
>>  
>> On the resource server, how do you know which key/value pair to put in which order for verification? Also, given that different server implementations express these incoming parameters in different ways, it seems problematic to be consistent.
>>  
>> Thanks.
>>  
>> -Brock
>>  
>> _______________________________________________
>> OAuth mailing list
>> [email-masked] <mailto:[email-masked]>
>> https://www.ietf.org/mailman/listinfo/oauth <https://www.ietf.org/mailman/listinfo/oauth>
>>  
>>  
>> _______________________________________________
>> OAuth mailing list
>> [email-masked] <mailto:[email-masked]>
>> https://www.ietf.org/mailman/listinfo/oauth <https://www.ietf.org/mailman/listinfo/oauth>