An adequate message authentication code for REST
Posted
by
Andras Zoltan
on Programmers
See other posts from Programmers
or by Andras Zoltan
Published on 2012-10-28T11:51:11Z
Indexed on
2012/10/28
17:16 UTC
Read the original article
Hit count: 316
My REST service currently uses SCRAM authentication to issue tokens for callers and users. We have the ability to revoke caller privileges and ban IPs, as well as impose quotas to any type of request.
One thing that I haven't implemented, however, is MAC for requests. As I've thought about it more, for some requests I think this is needed, because otherwise tokens can be stolen and before we identify this and deactivate the associated caller account, some damage could be done to our user accounts.
In many systems the MAC is generated from the body or query string of the request, however this is difficult to implement as I'm using the ASP.Net Web API and don't want to read the body twice. Equally importantly I want to keep it simple for callers to access the service.
So what I'm thinking is to have a MAC calculated on:
- the url, possibly minus query string
- the verb
- the request ip (potentially is a barrier on some mobile devices though)
- utc date and time when the client issues the request.
For the last one I would have the client send that string in a request header, of course - and I can use it to decide whether the request is 'fresh' enough.
My thinking is that whilst this doesn't prevent message body tampering it does prevent using a model request to use as a template for different requests later on by a malicious third party. I believe only the most aggressive man in the middle attack would be able to subvert this, and I don't think our services offer any information or ability that is valuable enough to warrant that.
The services will use SSL as well, for sensitive stuff. And if I do this, then I'll be using HMAC-SHA-256 and issuing private keys for HMAC appropriately.
Does this sound enough? Have I missed anything?
I don't think I'm a beginner when it comes to security, but when working on it I always. am shrouded in doubt, so I appreciate having this community to call upon!
© Programmers or respective owner