从 Rails 应用程序破解 CookieStore 创建的 cookie 有多容易?
我读过很多文章,说在 Rails 应用程序中使用 cookie 存储的一个缺点是客户端可以看到 cookie 数据。 不过,我查看了cookie数据,发现它是加密的。 解密cookie数据相对容易吗?
I have read a bunch of stuff saying that one con of using the cookie store in a Rails app is that the client can see the cookie data. However, I looked at the cookie data and it is encrypted. Is it relatively easy to decrypt the cookie data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Rails 中的默认 cookie 存储未加密,而是采用 Base64 编码。 Base64 编码只是一种用 ASCII 表示二进制数据的方法,无论如何都不应将其视为“加密”; 任何人都可以解码它。
The default cookie store in Rails isn't encrypted, it's Base64 encoded. Base64 encoding is simply a way to represent binary data in ASCII, and should not be thought of as "encryption" by any stretch of the imagination; anyone can decode it.
存储的会话数据使用您在 config.rb 文件中设置的以下信息进行签名。
因此,虽然阅读起来并不容易,但只要有足够的时间和精力,也不是不可能。
这里有一堆详细讨论这个问题的链接,但普遍的共识是,这不是一个有缺陷的实现,并且您不应该在会话中存储任何太关键的内容。
The session data stored is signed using the below information you setup in your config.rb file.
So while it is not easy to read, it is not impossible with enough time and effort.
Here is a bunch of link that discuss this issue at length but the general consensus is that this is not a flawed implementation and that you should not store anything in the session that is too critical.
值得注意的是,rails < 1.2.6 遭遇会话固定漏洞,可以轻松窃取他人的 ID/会话
Rails 1.2.4 发行说明
http://weblog.rubyonrails.org/ 2007/10/5/rails-1-2-4-maintenance-release
Rails 1.2.6 发行说明
http: //weblog.rubyonrails.org/2007/11/24/ruby-on-rails-1-2-6-security-and-maintenance-release
CVE-2007-5380
http://cve.mitre.org/cgi- bin/cvename.cgi?name=CVE-2007-5380
CVE-2007-6077
http://cve.mitre.org/cgi- bin/cvename.cgi?name=CVE-2007-6077
It is worth knowing that rails < 1.2.6 suffered from a session-fixation vulnerability makes it easy steal someone else's ID / session
Rails 1.2.4 Release Notes
http://weblog.rubyonrails.org/2007/10/5/rails-1-2-4-maintenance-release
Rails 1.2.6 Release Notes
http://weblog.rubyonrails.org/2007/11/24/ruby-on-rails-1-2-6-security-and-maintenance-release
CVE-2007-5380
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-5380
CVE-2007-6077
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6077