03 Dec 2009 @ 1:46 PM 

There are a number of ways to prevent replay attacks when writing RESTful webservices.

Each option will depend on your requirements.

For transactional webservices I have designed a method which i find to be reasonably secure

lets say that this is how your webservice is currently invoked

https://localhost:8181/someWebService/getVoucherNumber?service_provider_item_id=4&posuser_idnumber=7902115131088&posuser_pin=1234&license_code=cd15b372-cfec-11de-b323-82ddcd6bb138

this is all good and well, BUT any attacker can re-use this string as many times as they want.

The solution is to add another parameter. Lets call this parameter “signature”

To generate a signature, we do the following:

1) take the current UTCS datetime and format it like this “yyyy’-'MM’-'dd’ ‘HH’:'mm’:'ss”.
2) blowfish encrypt that string
3) hex encode the resulting string so we end up with something like this “60e215044148b7a4a831a16065b180fa4a823b91″

Now we call our webservice with the added parameter

https://localhost:8181/someWebService/getVoucherNumber?service_provider_item_id=4&posuser_idnumber=7902115131088&posuser_pin=1234&license_code=cd15b372-cfec-11de-b323-82ddcd6bb138&signature=60e215044148b7a4a831a16065b180fa4a823b91

The webservice does the following
1) hex decode the string
2) blowfish decrypt it
3) make sure that the resulting datetime stamp is within “10″ seconds of the current time

If the signature is valid, then continue processing the webservice request

Posted By: Zayin
Last Edit: 03 Dec 2009 @ 02:02 PM

EmailPermalink
Tags


 

Responses to this post » (2 Total)

 
  1. zayinkrige says:

    New Blog Post -> Preventing replay attacks when writing RESTful webservices – http://www.zayinkrige.com/preventing-rep

  2. [...] This post was mentioned on Twitter by Zayin Krige, Zayin Krige. Zayin Krige said: New Blog Post -> Preventing replay attacks when writing RESTful webservices – http://toast.tw/100akx [...]

Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.


 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 38
  • Comments » 61
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

Links



    No Child Pages.

Portfolio



    No Child Pages.