openimsdk / openimsdk/chat

[BUG] /user/find/full 越权漏洞

Open
#710 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
159
Forks
221
PR merge metrics
No merged PRs in 30d

Description

OpenIM Server Version

1.8.4

Operating System and CPU Architecture

Linux (AMD)

Deployment Method

Docker Deployment

Bug Description and Steps to Reproduce

使用当前用户xxx 的OpenIM 业务token,可直接查询另一个真实用户lll 的资料。响应返回phoneNumbernicknamegenderbirth、消息设置等字段,说明接口按传入userIDs 返回用户资料,未限制为当前用户或已授权关系范围

Image
Screenshots Link

internal/rpc/chat/user.go 中的 FindUserFullInfo 函数,增加权限校验:
func (o *chatSvr) FindUserFullInfo(ctx context.Context, req *chat.FindUserFullInfoReq) (*chat.FindUserFullInfoResp, error) {
opUserID, userType, err := mctx.Check(ctx)
if err != nil {
return nil, err
}
if len(req.UserIDs) == 0 {
return nil, errs.ErrArgs.WrapMsg("UserIDs is empty")
}

// 普通用户只能查询自己的信息
if userType == constant.NormalUser {
    for _, userID := range req.UserIDs {
        if userID != opUserID {
            return nil, errs.ErrNoPermission.WrapMsg("normal user can only query own info")
        }
    }
}

attributes, err := o.Database.FindAttribute(ctx, req.UserIDs)
if err != nil {
    return nil, err
}
return &chat.FindUserFullInfoResp{Users: DbToPbUserFullInfos(attributes)}, nil

}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in internal/rpc/chat/user.go at chatSvr.FindUserFullInfo, then read the surrounding mctx.Check and user-type handling. Reproduce the request with a normal user's token and another user's ID, and verify that ordinary users cannot retrieve other users' full profiles while the intended permitted lookup still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, authorization, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.