Are Laravel 4 session variables secure?

耗尽温柔 提交于 2019-11-28 05:29:42

问题


Is there any (known) way for end users to edit a Laravel 4 session variable?


回答1:


Is there any (known) way for end users to edit a Laravel 4 session variable?

Yes there is, but only if you go out of your way to make it possible. The steps required are:

  1. Use the cookie driver for sessions (which stores all session data into a cookie rather than simply storing an identifier in the cookie and keeping the actual data server-side). I generally recommend against storing session state in a cookie.
  2. Turn off session encryption, which the documentation strongly says not to do.

If you do these ill-advised steps, in addition to allowing users to overwrite session data, this is a risk for PHP object injection via unserialize().

Advice: If you are going to store session state in a cookie, make sure it's wrapped in authenticated encryption. Laravel's encryption library employs authenticated encryption (Encrypt then MAC), and the sessions use this by default.


As for the other drivers, that depends on your network topology. If your database is on another server and your attacker can impersonate the web server, they can put whatever they want in the database.

Last I checked, Laravel defaults to encrypt session data (unless you disable encryption). Unless your database is on the same host as the webserver, leave it turned on.




回答2:


They would have to run code (something like Session::put('key', 'value');) on your server.. or take advantage of possible vulnerabilities on your application.

If you're using the Session carefully on your side (validation, etc.) it should remain the same unless you update it.

More on Laravel's Session here: http://laravel.com/docs/4.2/session



来源:https://stackoverflow.com/questions/31948725/are-laravel-4-session-variables-secure

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