修复邮件详情与规则更新的水平越权漏洞 (#351)

* fix(auth): enforce email detail ownership

* fix(rules): scope updates to owning user
This commit is contained in:
NikoCat233 2026-07-22 15:58:56 +08:00 committed by GitHub
parent da55756917
commit 593c3fb720
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -61,7 +61,7 @@ func UpsertRule(ctx *context.Context, w http.ResponseWriter, req *http.Request)
func save(ctx *context.Context, p *models.Rule) error {
if p.Id > 0 {
_, err := db.Instance.Exec(db.WithContext(ctx, "update rule set name=? ,value = ? ,action = ?,params = ?,sort = ? where id = ?"), p.Name, p.Value, p.Action, p.Params, p.Sort, p.Id)
_, err := db.Instance.Exec(db.WithContext(ctx, "update rule set name=? ,value = ? ,action = ?,params = ?,sort = ? where id = ? and user_id = ?"), p.Name, p.Value, p.Action, p.Params, p.Sort, p.Id, ctx.UserID)
if err != nil {
return errors.Wrap(err)
}

View File

@ -20,7 +20,7 @@ import . "xorm.io/builder"
func GetEmailDetail(ctx *context.Context, id int, markRead bool) (*response.EmailResponseData, error) {
// 先查是否是本人的邮件
var ue models.UserEmail
_, err := db.Instance.Where("email_id = ?", id).Get(&ue)
_, err := db.Instance.Where("email_id = ? AND user_id = ?", id, ctx.UserID).Get(&ue)
if err != nil {
log.Error(err)
}