IDOR(Insecure Direct Object Reference) 취약점이 뭔가요? 어떻게 방어하나요?
IDOR은 URL이나 파라미터의 ID를 변경하여 다른 사용자의 데이터에 접근하는 취약점입니다.
# 취약한 예시GET /api/users/123/profile ← 내 프로필GET /api/users/124/profile ← 다른 사람 프로필도 보임!GET /api/orders/1001 ← 내 주문GET /api/orders/1002 ← 남의 주문도 보임!
방어:
// 나쁜 코드app.get("/api/orders/:id", async (req, res) => { const order = await db.order.findById(req.params.id); res.json(order); // 누구 것이든 반환});// 좋은 코드app.get("/api/orders/:id", async (req, res) => { const order = await db.order.findFirst({ where: { id: req.params.id, userId: req.user.id } // 본인 것만 }); if (!order) return res.status(404).json({ error: "Not found" }); res.json(order);});
OWASP Top 10에서 1위인 Broken Access Control의 대표적인 예입니다.
댓글 1
IDOR은 URL이나 파라미터의 ID를 변경하여 다른 사용자의 데이터에 접근하는 취약점입니다.
방어:
OWASP Top 10에서 1위인 Broken Access Control의 대표적인 예입니다.