是否可以修改 $_SESSION 变量?
恶意用户是否可以将 $_SESSION(在 php 中)变量设置为他想要的任何值?
Is it possible for an malicious user to set the $_SESSION (in php) variable to any value he wants?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
很大程度上取决于您的代码。非常明显的事情:
$_SESSION['username'] = $_REQUEST['username']
。Highly depends on your code. Something very obvious:
$_SESSION['username'] = $_REQUEST['username']
.是的,通过使用其他用户的会话数据,如下所示: http://phpsec.org/projects/指南/4.html
Yes, by using another user's session data, as shown here: http://phpsec.org/projects/guide/4.html
这取决于您如何设置会话变量。用户可以利用您设置它们的方式。
最常见的会话攻击是会话固定:http://en.wikipedia.org/wiki/Session_fixation
It depends on how you set the sessions variable. An user can exploit the way you set them.
The most common attacks with sessions is session fixation : http://en.wikipedia.org/wiki/Session_fixation
如果你为他提供了一种方法(糟糕/不安全的代码),这是可能的。然而,这通常不太可能。
If you provide a means for him to do so (bad/insecure code), it is possible. However, this is generally unlikely.
通常不会,但如果例如您的 PHP 中存在远程代码执行漏洞,则可能会出现这种情况。
Not typically, but they could if, for instance, you had a remote code execution vulnerability in your PHP.
除非你在代码中做错了什么,否则他无法在你的服务器上设置它,他能做的就是窃取其他用户的会话cookie并以这种方式进入......换句话说;他可以更改自己的会话 cookie,您的 $_SESSION 使用该 cookie 来识别他的身份
Unless you have done something wrong in your code he cant set it on your server, what he can do is steal some other users session cookie and get in that way... in other words; he can change his own session cookie that your $_SESSION use to identify him
不,如果您的代码正确并且不允许根据未经验证的用户输入设置值,则不会。
No, not if your code is correct and doesn't allow to set values based on unverified userinput.
是的。如果您使用用户可以编辑的 cookie 或其他类似请求方法中的内容来与会话进行交互,那么就会发生变化。例如,假设您创建了一个在线商店并将项目 ID 存储在 cookie 中,并在页面刷新时将其推送到会话中。在页面上时,用户可以编辑 cookie,因此当进入会话时,它已被修改。
Yes. If you use something from a cookie or another similar request method that a user can edit to interact with the session then there is a change. For example say you make an online store and store the item id's in the cookie and on page refresh pushes it into the session. While on the page a user can edit the cookies so when it goes into the session it have been modified.
是的,当 REGISTER_GLOBALS 开启时。
Yes, when REGISTER_GLOBALS in on.