A Method for Preventing Replay in APP Applications

Posted in http, privacy/secrecy/security, web-services at 12:11 pm by Josh Peters

Today I read an article on Pete Lacey’s blog about using message-level security in REST applications (especially using the Atom Publishing Protocol). There was a comment by Bob McCormick that I found interesting. Bob pointed out that the protocol is vulnerable to replay attacks.

A replay attack (if you don’t already know) is when a duplicate transaction is run against an account of some sort. I’m sure you’ve seen duplicate comments on a blog because someone clicked submit twice (don’t double-click on web forms, ‘kay?) or something similar.

Here is a simple method for preventing replay attacks in an APP application. It requires client-level support of ETags, but that shouldn’t be too much to ask. Say you want to purchase something on a mythical site (http://example.com/). You could do the following to make a transaction (a variant on what is currently in an example in the draft):

  1. Create a transaction using POST
  2. The server provides an ETag back with the response (as well as a content location URI).
  3. The client then PUTs the payment information to the URI specified in the content location, with a If-Match header. This is important, as the server should not accept any PUT requests without the proper ETag.
  4. If the entities match, the server accepts the PUT, otherwise 412 Precondition Failed. A new ETag SHOULD be generated upon the PUT and the credentials used to execute the PUT (say WSSE UsernameToken) should be invalidated. These two bits combine to ensure that the original transaction has taken place. A client can then GET the URI with the If-None-Match header set to the original ETag to ensure the transaction went through (in this case, a 304 Not Modified indicates that the transaction failed).

This method should work for most sensitive transactions but I admit it seems odd to make the 304 indicate failure.

Track with co.mments

Leave a Reply

Spam Protection by WP-SpamFree