/보안/OWASP API Security Top 10: Practical Vulnerability Analysis and Defensive Code
SecurityOWASPAPI보안

OWASP API Security Top 10: Practical Vulnerability Analysis and Defensive Code

APIs sit at the core of modern applications, and OWASP updated its API Security Top 10 in 2023. This post walks through the critical risks with vulnerable vs. fixed code and practical mitigations.

OWASP API Security Top 10: Practical Vulnerability Analysis and Defensive Code

Why API Security Matters

APIs are the core of modern applications. OWASP updated the API Security Top 10 in 2023.

API1:2023 — Broken Object Level Authorization (BOLA)

This is the most common and most critical vulnerability.

Vulnerable code

JavaScript
// GET /api/orders/{orderId}
app.get('/api/orders/:orderId', async (req, res) => {
  // 문제: 현재 사용자 소유 여부 확인 없음
  const order = await Order.findById(req.params.orderId);
  res.json(order);
});

Fixed code

JavaScript
app.get('/api/orders/:orderId', authenticate, async (req, res) => {
  const order = await Order.findOne({
    _id: req.params.orderId,
    userId: req.user.id  // 소유자 검증 필수
  });
  if (!order) return res.status(403).json({ error: 'Forbidden' });
  res.json(order);
});

API2:2023 — Broken Authentication

Secure JWT configuration

JavaScript
import jwt from 'jsonwebtoken';

const token = jwt.sign(
  { userId: user.id },
  process.env.JWT_SECRET,
  { algorithm: 'HS256', expiresIn: '1h' }
);

// 검증 시 알고리즘 명시 필수
const decoded = jwt.verify(token, process.env.JWT_SECRET, {
  algorithms: ['HS256']
});

API3:2023 — Broken Object Property Level Authorization

JavaScript
// 잘못된 예: 전체 객체 반환
res.json(user);  // password_hash, internal_id 등 포함

// 올바른 예: 필요한 필드만 선택
const { id, name, email } = user;
res.json({ id, name, email });

API4:2023 — Unrestricted Resource Consumption

JavaScript
import rateLimit from 'express-rate-limit';

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000,
  max: 100,
  message: { error: 'Too many requests' }
});

app.use('/api/', limiter);

API5–10: Key Takeaways

RankVulnerabilityKey mitigation
API5Function Level AuthorizationRole-based access control (RBAC)
API6Unrestricted Business FlowsRate limiting on business logic
API7Server Side Request ForgeryValidate against a URL allowlist
API8Security MisconfigurationDisable unused HTTP methods
API9Improper Inventory ManagementAPI version management
API10Unsafe Consumption of APIsValidate third-party API responses

API security must start in the development phase. Fixing issues after deployment costs 10–100× more.

References: Official Documentation

The primary sources for the behavior, configuration, and errors covered in this article are the official documents below. Check them for version-specific options and exact behavior.

확인 정보
✦ ✦ ✦
편집 검토 · Editorial Review

Nodelog는 모든 콘텐츠의 내용과 출처를 공개 전에 검토합니다. 환경(OS·버전)에 따라 결과가 달라질 수 있는 기술 정보는 공식 문서와 함께 확인하며, 검토 기준과 정정 원칙은 편집 정책에서 안내합니다. 오류를 발견하시면 이메일로 제보해 주세요 — 확인 후 신속히 정정합니다.

편집 책임 · Nodelog 기술 편집팀·발행 · ·업데이트 ·
관련 공식 문서OWASP 공식 문서

Comments

Be the first to comment.