【问题标题】:Can any malicious user change his user_id and get other users updates in web sockets?任何恶意用户都可以更改他的 user_id 并在 Web 套接字中获取其他用户的更新吗?
【发布时间】:2019-02-17 11:58:50
【问题描述】:

我将Laravel Echo 用于套接字。

在我的 html 中,我有:

<input type="hidden" id="user_id" value="<?php echo $user_id; ?>">

当用户更新她/他的个人资料时,我会在我的后端触发一个事件。现在在Echo 我有以下代码:

window.Echo.private('authenticate-user.' + user_id)
    .listen('ProfileUpdated', (updates) => {
        console.log(updates);
    });

我的问题是,恶意用户是否可以更改她/他的user_id 以便在authenticate-user 私人频道中作为另一个用户加入并获取其他用户的更新?!虽然当页面加载时它会得到该 user_id 并加入频道中的用户,所以她/他不能在页面完全加载之前执行此操作,但我怀疑她/他是否可以在网络概念中做一些恶意的事情。顺便说一句,我有 ids 散列但大概不是。

【问题讨论】:

    标签: php laravel sockets security authentication


    【解决方案1】:

    使用这个$id = Auth::id();

    (https://laravel.com/docs/5.7/authentication#retrieving-the-authenticated-user)

    这将在服务器端获取 id

    【讨论】:

      猜你喜欢
      • 2013-07-05
      • 1970-01-01
      • 2018-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-10
      • 1970-01-01
      相关资源
      最近更新 更多