Is using an HMAC in web service messages overkill if you are already using SSL and Access Tokens?

I’m thinking of further ways to secure a service, and HMAC message signing is one. But it comes with a cost, more complicated to implement, not as standard, etc. So I would need some really good reasons to recommend adding message signing on top of SSL and Access Tokens.



SSL already provides a secure connection which protects data in transit between client and server. It ensures confidentiality and integrity, and, indeed, uses HMAC for the latter. If your security model is about attackers who might try to alter messages while they travel from the client to the server and back, then adding your own HMAC is redundant and useless.

SSL, though, is pure tunnelling. It ceases to act when the data has reached its destination. If your security model is about an attacker who may modify data stored on your server, then the fact that SSL was used to transfer such data contributes nothing to the protection against that attacker. In that setup, the actual existence of a client and a network is irrelevant; this is a storage problem, not a network problem. HMAC may help, but only if the attacker cannot learn the HMAC key, which is a restrictive scenario.

The really important question to ask first is: what can the envisioned attacker actually do ?

  • In the scenario I'm considering I am really only focusing on the message transport over the internet, so like you said SSL is probably going to do the job here. I was thinking an additional HMAC on top of SSL would protect against a man in the middle attack, since they could fake the SSL signing, but probably not my custom HMAC - since the secret would be assumed secure on the server sending the request. But is the man-in-the-middle even a valid threat to be concerned with?
    – Paul Fryer
    Jan 16 '14 at 16:22
  • If you have a shared secret on both sides of the connection, then you could use it as basis for SSL with the "PSK" cipher suites. But, really, SSL is protected against MitM (as long as you don't do anything stupid like making the client accept just any server certificate without validation). Jan 16 '14 at 16:35
  • Thanks Thomas, very helpful. A side related question: Why do you think Amazon chose to use a custom HMAC scheme instead of SSL? docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
    – Paul Fryer
    Jan 16 '14 at 16:57
  • I think i answered my own question about Amazon: they basically use HMAC just to identify a caller.
    – Paul Fryer
    Jan 16 '14 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.