akctba / akctba/secret-santa-go-api

Add rate limiting and request size limits

未關閉
#28 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement Security
主要語言
Go
星號
0
分支
0
PR 合併指標
30 天內沒有已合併 PR

描述

## Problem

The API has no rate limiting or request body size restrictions. This exposes it to:

- **Brute-force attacks** on `/user/signin` (OWASP A07: Identification and Authentication Failures)
- **DoS via large payloads** — a client can send arbitrarily large request bodies
- **Enumeration attacks** on user/group endpoints

## Expected Behavior

- Requests to sensitive endpoints (especially `/user/signin`) should be rate-limited per IP.
- Request body sizes should be capped at a reasonable limit.

## Suggested Fix

1. Add a rate-limiting middleware using a package like `golang.org/x/time/rate` or `github.com/ulule/limiter`.
2. Wrap the router handler with `http.MaxBytesReader` to cap request body size (e.g., 1MB).

## Affected Files
- `main.go`
- `controllers/middleware.go`

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。