master-project
CHAPTER 43 / 50
읽기 약 2분
FUNCTION
보안 체크리스트: OWASP Top 10 점검
핵심 개념
OWASP Top 10·CSP·Rate Limit·SQL Injection·XSS·CSRF — 출시 전 보안 점검.
본문
OWASP Top 10 (2021 → 2025)
A01 Broken Access Control — RLS·인증
A02 Cryptographic Failures — HTTPS·secret 관리
A03 Injection — SQL·XSS
A04 Insecure Design — 위협 모델링
A05 Security Misconfiguration — CSP·secrets
A06 Vulnerable Components — npm audit
A07 Authentication Failures — 비밀번호·세션
A08 Data Integrity Failures — webhook 서명
A09 Logging Failures — Sentry·audit log
A10 SSRF — URL 화이트리스트A01 Broken Access Control
✓ Supabase RLS 모든 테이블 enable
✓ Server Action에서 user.id 체크 (RLS 추가 보호)
✓ 본인 리소스만 조회·수정·삭제 (.eq('user_id', user.id))
✓ Admin 페이지 분리 (role check)
❌ /api/admin/users → 인증 안 거치고 호출 가능
✓ middleware + admin role 검증A02 Cryptographic Failures
✓ HTTPS 강제 (HSTS preload)
✓ .env Sensitive (Vercel Secret)
✓ 비밀번호: bcrypt (Supabase 자동)
✓ API 키: SHA-256 hash 저장
✓ JWT 키 회전 (1년마다)
❌ http:// 허용 → man-in-the-middle
✓ next.config.ts HSTS headerA03 Injection
// SQL Injection — Supabase Client는 자동 parameterize
✅ supabase.from('x').select().eq('id', userInput) // 안전
❌ supabase.rpc('raw', { sql: `... ${userInput}` }) // 위험
// XSS
❌ <div dangerouslySetInnerHTML={{ __html: userInput }} /> // 위험
✅ <div>{userInput}</div> // React 자동 escape
✅ DOMPurify.sanitize(html) // 마크다운 등 필요 시
// 마크다운 렌더
import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeSanitize from 'rehype-sanitize' // ← 필수
import rehypeStringify from 'rehype-stringify'
const html = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeSanitize) // XSS 방지
.use(rehypeStringify)
.process(markdown)A04 Insecure Design
[위협 모델링]
- 누가 공격하나? (외부 / 내부 / 봇)
- 무엇을 노리나? (PII / 결제 / 콘텐츠)
- 어떻게? (XSS / SQL / 사회공학)
- 어떻게 막나? (각 레이어)
[방어 다층]
- DDoS: Cloudflare
- Rate limit: Upstash
- WAF: Vercel Web Application Firewall
- 코드 검증: ESLint security plugin
- DB: RLS + ParameterizedA05 Security Misconfiguration
// CSP (Content Security Policy)
{
key: 'Content-Security-Policy',
value: [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' https://www.googletagmanager.com",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' https: data:",
"connect-src 'self' https://*.supabase.co https://api.stripe.com",
"frame-src https://js.stripe.com",
].join('; '),
}[기타]
✓ X-Frame-Options: DENY (clickjacking)
✓ X-Content-Type-Options: nosniff
✓ Referrer-Policy: strict-origin-when-cross-origin
✓ Permissions-Policy: camera=(), microphone=()
✓ Server 헤더 제거 (poweredByHeader: false)A06 Vulnerable Components
# 매주 자동
pnpm audit
pnpm audit fix
# Dependabot (GitHub)
# .github/dependabot.yml
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule: { interval: 'weekly' }
open-pull-requests-limit: 5A07 Authentication Failures
✓ 비밀번호 8자 이상 + 복잡도
✓ Magic Link · OAuth (passwordless 권장)
✓ 세션 만료 (1시간 access, 7일 refresh)
✓ 비밀번호 재설정 토큰 1회용·15분
✓ 무차별 대입 차단 (rate limit)
❌ 비밀번호 평문 저장
✓ bcrypt (Supabase 자동)A08 Data Integrity (Webhook)
// Stripe webhook 서명 검증 (CH.32)
const event = stripe.webhooks.constructEvent(body, signature, secret)
// 위변조 시 throwA09 Security Logging
[기록]
- 로그인 성공·실패
- 비밀번호 변경
- 결제·환불
- 관리자 작업
[Sentry + audit_log 테이블]A10 SSRF
// 사용자 URL 입력 시 (예: 이미지 URL fetch)
const ALLOWED_HOSTS = ['cdn.mysaas.com', 'images.unsplash.com']
function safeFetch(url: string) {
const parsed = new URL(url)
if (!ALLOWED_HOSTS.includes(parsed.hostname)) throw new Error('not allowed')
// 내부 IP 차단
if (parsed.hostname.match(/^(127\.|10\.|192\.168\.)/)) throw new Error('internal')
return fetch(url)
}보안 검사 도구
[자동]
- npm audit
- Snyk
- GitHub CodeQL
- ESLint security plugin
[수동]
- OWASP ZAP scanner
- Burp Suite
- Mozilla Observatory (https://observatory.mozilla.org)다음 챕터 (수익화 시작)
CH.44 "결제 연동: Stripe Checkout + 웹훅".
AI 프롬프트
🤖 AI에게 잘 물어보는 법 — 모델·전략별 프롬프트
Claude
무료: Sonnet 4.6 / Pro $20/mo: Opus 4.6
내 마스터 프로젝트의 보안 체크리스트 부분을 분석해서 실전 적용 + 개선 우선순위 3가지를 알려줘.
ChatGPT
무료: GPT-5.5 / Plus $20/mo: GPT-5.5 Pro
보안 체크리스트 관련 모범 사례·안티패턴 5개를 비교 분석해서 실전 적용를 위한 추천 방안을 알려줘.
Gemini
무료: 2.5 Flash / Pro $19.99/mo: 3.1 Pro
내 프로젝트 전체에서 보안 체크리스트 최적화 가능 위치와 리스크를 보고해줘.
Grok
무료: Grok 4.1 / SuperGrok $30/mo
2026년 한국 1인 개발자 시장의 보안 체크리스트 트렌드와 차별화 포인트를 정리해줘.
⭐ 이것만 기억하세요
보안 체크리스트: OWASP Top 10 점검은 이 3가지만 확실히 잡으세요
1.OWASP Top 10 = 출시 전 점검 표준
2.RLS + CSP + Rate Limit + 서명 검증 = 4중 방어
3.다음 챕터에서 Stripe 결제
공유하기
진행도 43 / 50