What's the purpose of tainting Ruby objects?

对着背影说爱祢 提交于 2019-12-30 06:02:53

问题


I'm aware of the possibility to mark untrusted objects as tainted, but what's the underlying purpose and why should I do it?


回答1:


It used to be a pretty standard practice when writing CGIs in Perl. There is even a FAQ on it. The basic idea was that the run time could guarantee that you did not implicitly trust a tainted value.




回答2:


One tracks taint as a security precaution, in order to ensure that untrusted data isn't mistakenly used for calculations, transactions, or interpreted as code.

Tracking taint via a built-in language feature is more clear and more reliable than tracking via coding conventions or relying on code review.

For example, input from the user can generally be considered 'untrusted' until it has been sanitized properly for insertion into the database. By marking the input as tainted, Ruby ensures satisfactory sanitation takes place and prevents a potential SQL injection attack.

For an example of an "ancient" (2005) coding practice that demonstrates how taint was tracked without such Perl and Ruby modules, read some good old Joel:

http://www.joelonsoftware.com/articles/Wrong.html



来源:https://stackoverflow.com/questions/1736161/whats-the-purpose-of-tainting-ruby-objects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!