Skip to content

Avatar upload lets one user overwrite another’s profile image #99

@YLChen-007

Description

@YLChen-007

Avatar upload lets one user overwrite another’s profile image: /member/imgaeUpload accepts userId and token but never verifies that the token belongs to that user before updating DB records, so any authenticated user can change another user’s avatar.

    public Result<Object> imgaeUpload(@RequestBody CommonDto common){
        String imgPath = memberService.imageUpload(common.getUserId(),common.getToken(),common.getImgData());
        return new ResultUtil<Object>().setData(imgPath);
    }
    public String imageUpload(Long userId,String token,String imgData) {
        TbMember tbMember=tbMemberMapper.selectByPrimaryKey(userId);
        // updates the target record with no token/userId consistency check
        tbMemberMapper.updateByPrimaryKey(tbMember);
        Member member=loginService.getUserByToken(token);
        member.setFile(imgPath);
        jedisClient.set("SESSION:" + token, new Gson().toJson(member));
        return imgPath;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions