Tags

The following entries are tagged with “ezcrypto”:

A tamper-proof cookie jar for Rails

When the default session store for Rails was changed to use cookies last year it caused quite a furore: "It’s not secret! It’s not safe!" The truth is it was never meant to be: in most circumstances you shouldn’t really be storing data in cookies that need to be protected so strongly. But I don’t really want to re-open that can of worms! Instead I want to look at a different cookie-related situation that arose during some optimisation work I’ve been doing on an existing Rails application.

No cookie monstersThe scenario is straightforward enough: the application stores a numeric record ID in a persistent cookie that, while perfectly safe to be seen by users, shouldn’t be changed by them. The solution currently used in the application is equally straightforward: the data is encrypted (using the EzCryto gem and AES encryption) before being written to the cookie, and then decrypted when the data is read back in.

In situations where cookie contents really shouldn’t be seen by users then encryption is the way to go (unless of course you can find a way of not using a cookie at all), however for a simple numeric ID where tampering is the only thing we need to protect against then it seems like overkill. A better solution is to take inspiration from the Rails cookie session store and use a HMAC.

Read more of this entry

Recent entries

Archives

  1. August 2010
  2. July 2010
  3. April 2010
  4. January 2010
  5. November 2009
  6. September 2009
  7. August 2009
  8. July 2009
  9. June 2009
  10. May 2009
  11. April 2009
  12. March 2009
  13. February 2009
  14. December 2008
  15. November 2008
  16. September 2008
  17. August 2008
  18. July 2008
  19. June 2008
  20. May 2008
  21. April 2008
  22. March 2008
  23. February 2008
  24. January 2008
  25. December 2007
  26. November 2007

Tags

  1. actioncontrollerdispatcher (nameerror)
  2. actionview
  3. active messaging
  4. activerecord
  5. activesupport
  6. actverecord
  7. aes
  8. aggregation
  9. ajax
  10. akismet
  11. amazon
  12. amazon sqs
  13. ami
  14. apache
  15. api
  16. apple
  17. apr
  18. apr-util
  19. async
  20. attachments
  21. attachment_fu
  22. attr_accessible
  23. auto scaling
  24. autotest
  25. availability
  26. aws
  27. backgroundrb
  28. beanstalkd
  29. bindings
  30. bj
  31. block
  32. branding
  33. buckets
  34. bug
  35. bugmash
  36. cache
  37. caching
  38. callbacks
  39. cancer research uk
  40. cdn
  41. centos
  42. charity
  43. cloud
  44. cloudfront
  45. clusters
  46. column information
  47. columns
  48. community
  49. company name
  50. compatibility
  51. compiler
  52. composed_of
  53. consultancy
  54. content
  55. content delivery
  56. controller
  57. convert
  58. cookies
  59. csrf
  60. css
  61. data warehouse
  62. database
  63. dates
  64. defensio
  65. deployment
  66. design
  67. development
  68. dhtml
  69. docrails
  70. documentation
  71. donations
  72. drdb
  73. duplicate key
  74. ebs
  75. ec2
  76. elastic
  77. elastic block store
  78. elastic load balancing
  79. encoding
  80. encryption
  81. erb
  82. error
  83. european
  84. events
  85. ezcrypto
  86. facebook
  87. fckeditor
  88. feedburner
  89. feeds
  90. ffmpeg
  91. filter
  92. fixes
  93. flash
  94. flickr
  95. flickr api
  96. flickr_fu
  97. fuse
  98. geekup
  99. gems
  100. geocode
  101. git
  102. github
  103. god
  104. great south run
  105. greenplum
  106. growl
  107. hacker
  108. haml
  109. haproxy
  110. helper
  111. hmac
  112. holiday
  113. hooks
  114. hosting
  115. howto
  116. hpricot
  117. html
  118. identity
  119. imagemagick
  120. imagescience
  121. infinidb
  122. infiniteftp
  123. infobright
  124. init.d
  125. insert
  126. invalid authenticity token
  127. italy
  128. javascript
  129. jquery
  130. json
  131. leeds media
  132. limit
  133. linkrenderer
  134. linux
  135. load balancing
  136. logo
  137. mac
  138. markaby
  139. mass-assignment
  140. memcached
  141. mephisto
  142. messaging
  143. middleware
  144. migrate
  145. migration
  146. model
  147. mod_rails
  148. mod_ruby
  149. monetdb
  150. mongrel
  151. mongrel_cluster
  152. monit
  153. monitoring
  154. mootools
  155. mp3
  156. mq
  157. multiple gems
  158. multiselect
  159. mysql
  160. neon
  161. new site
  162. nginx
  163. observer
  164. offset
  165. open source
  166. opensolaris
  167. openssl
  168. optimisation
  169. pagination
  170. paperclip
  171. parameters
  172. params
  173. passenger
  174. patch
  175. performance
  176. permanentredirect
  177. persistence
  178. persistent storage
  179. persistentfs
  180. php
  181. phusion
  182. plugin
  183. plugins
  184. post commit
  185. post-commit
  186. protomultiselect
  187. prototype
  188. query
  189. queues
  190. quotes
  191. race for life
  192. rack
  193. rails
  194. rails development
  195. rails patch
  196. rails plugin
  197. rails-doc
  198. rails3
  199. rake
  200. refresh
  201. renderer
  202. respond_to
  203. rich text editor
  204. rmagick
  205. ruby
  206. ruby on rails
  207. rubyinline
  208. running
  209. rvideo
  210. s3
  211. s3fs. elasticdrive
  212. scaling
  213. schema
  214. schwarzenegger
  215. scm
  216. security
  217. services
  218. session
  219. shorthand
  220. snarl
  221. social
  222. solaris
  223. spam filter
  224. sparrow
  225. specify
  226. sponsorship
  227. sql
  228. sqlite3
  229. sql_logging
  230. starling
  231. starter kit
  232. storage
  233. streaming
  234. subversion
  235. sue ryder care
  236. survey
  237. svn
  238. swfupload
  239. swig
  240. sysadmin
  241. tables
  242. tamper
  243. templates
  244. the webfellas
  245. thewebfellas
  246. thin
  247. thumbnail
  248. time zone
  249. tinymce
  250. tip
  251. tips
  252. to-done
  253. training
  254. transcoding
  255. twitter
  256. tzinfo
  257. uk
  258. uk rails
  259. unsigned
  260. update
  261. uploads
  262. url
  263. validation
  264. version
  265. video
  266. view
  267. vmdk
  268. vmware
  269. webfellas
  270. webfellows
  271. wedding
  272. welcome
  273. widgeditor
  274. will_paginate
  275. win32
  276. windows
  277. wysiwyg
  278. xen
  279. xhtml
  280. xvm
  281. youtube
  282. zenoss
  283. zentest
  284. zfs

Flickr snaps