2

OK - I'm trying to design a system that can provide personalised/differentiated content at minimal expense to the server.

One of the designs I'm currently exploring is where the request is somehow signed using a key/value pair where the value is secret, e.g.:

Original URL: /posts/foo?format=json

Secret pair (known to server and client):
    ABCDE: 12345

Hash: HMAC('/posts/foo?format=json', '12345')

Actual URL: /posts/foo?format=json&ABCDE=<hash>

(A safer method would be to include in an HTTP header, but let's ignore that for now).

Obviously, a non-safe action would have to have a nonce (to avoid replay) - but I was hoping to not demand a nonce for GET requests, and instead just return the content symmetrically encrypted using `12345' (the secret value) as the key.

This means that the hash for a particular URL could be precomputed by the server, and it could just return the (cached) encrypted content. If the content included a message-digest (again using 12345) then this could be tamper-proof over insecure connections.

Are there negative security implications to verifying using a hash like this, or using this symmetric key as the secret?

(Edited: replaced "sha1" with some HMAC)

cloudfeet
  • 2,548
  • 18
  • 22
  • 1
    I have a feeling you're trying to reinvent HMAC. – Adi Dec 13 '13 at 12:35
  • Don't attempt to build a MAC from a Hash. It usually goes wrong, often fatally. Use HMAC, as Adnan suggested. – CodesInChaos Dec 13 '13 at 12:50
  • How would you design your system if server load was not a problem? You may do better to start from there and then optimise your design. – paj28 Dec 13 '13 at 12:51
  • But if at all possible, use SSL. Properly configured SSL (session resumption, etc.) is pretty cheap and prevents many attacks, including replays. – CodesInChaos Dec 13 '13 at 12:52
  • @Adnan, @CodesInChaos - I am not using this as a MAC. The hash is not of the content, it is of the URL and the secret. The goal is to get an unguessable (but predictable if the secret is known) value for ABCDE for each URL. – cloudfeet Dec 18 '13 at 17:21
  • @CodesInChaos - Replay attacks are an issue - but what replay attacks can one perform with a GET? – cloudfeet Dec 18 '13 at 17:29
  • For the key reuse part see Why can't I use the same key for encryption and MAC? 2) You are using this as a MAC on the url. The requirements you listed are those of a MAC. Most homebrew MACs are broken, your original design was flawed, but not as bad as some similar variants. 3) I still think SSL is far better than any of this.
  • – CodesInChaos Dec 18 '13 at 18:45