AOSSIE-Org / AOSSIE-Org/DebateAI

[FEATURE]: /profile Elo update endpoint lets any authenticated client set arbitrary users' ratings

Đang mở
#392 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
TypeScript
Star
84
Fork
198
Merge trung bình
2 ngày 19 giờ
Pull request đã merge (30 ngày)
30

Mô tả

### Feature and its Use Cases

## Description
`UpdateEloAfterDebate` in `backend/controllers/profile_controller.go` (lines 352-381) reads `winnerId` and `loserId` straight from the request body and updates both users' ratings with no verification that:
- the caller was a participant in any debate,
- a debate between those users actually happened,
- the caller isn't naming themselves as winner repeatedly.

It is also a plain FindOne → `$set` read-modify-write with no transaction, so concurrent calls lose updates.

### Additional Context

## Impact
Any logged-in user can farm rating (or zero out other players) with a few `curl` calls, making the leaderboard meaningless.

## Suggested Fix
Derive winner/loser server-side from the stored debate result (the websocket/judge flow already knows the outcome) and remove the client-supplied IDs. Use an atomic update (`$inc` or optimistic concurrency on a version field).

### Code of Conduct

- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Start in backend/controllers/profile_controller.go at UpdateEloAfterDebate (lines 352-381), then trace the websocket/judge flow and the stored debate result it uses. Review the current FindOne → $set path and verify that completion derives the outcome server-side, prevents unauthorized rating changes, and preserves concurrent updates.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go, mongodb
Lĩnh vực
authorization, backend, databases, security
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.