From f5aa4ec5f0c5fe8ffbc3b3672ab3e66d00c7ab97 Mon Sep 17 00:00:00 2001 From: seoyunje Date: Thu, 12 Nov 2026 15:26:33 +0900 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=94=A7=20Add=20shared=20Claude=20Code?= =?UTF-8?q?=20project=20permissions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/settings.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .claude/settings.json diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 00000000..7d7563d2 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,24 @@ +{ + "permissions": { + "allow": [ + "Bash(ruff check *)", + "Bash(ruff format *)", + "Bash(pytest *)", + "Bash(git status *)", + "Bash(git diff *)", + "Bash(git log *)", + "Bash(npm test *)" + ], + "ask": [ + "Bash(git push *)" + ], + "deny": [ + "Read(**/.env)", + "Read(**/.env.local)", + "Read(**/.env.*.local)", + "Edit(**/.env)", + "Edit(**/.env.local)", + "Edit(**/.env.*.local)" + ] + } +} From d6c6f5f1efa58c6831923c4636a8567a9984a6eb Mon Sep 17 00:00:00 2001 From: seoyunje Date: Thu, 19 Nov 2026 18:21:46 +0900 Subject: [PATCH 2/9] =?UTF-8?q?=F0=9F=8E=A8=20Drop=20unneeded=20f-string?= =?UTF-8?q?=20prefix=20from=20auth=20SQL=20queries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/services/auth_svc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/App/services/auth_svc.py b/App/services/auth_svc.py index 8aaeaacd..2bfd6762 100644 --- a/App/services/auth_svc.py +++ b/App/services/auth_svc.py @@ -46,7 +46,7 @@ async def get_user_by_email(conn: Connection, email: str) -> UserData | None: HTTPException 500: When an unexpected exception occurs. """ try: - query = f""" + query = """ SELECT id, name, email from user where email = :email """ @@ -86,7 +86,7 @@ async def register_user(conn: Connection, name: str, email:str, hashed_password: HTTPException 400: When the DB INSERT fails or the request data is invalid. """ try: - query = f""" + query = """ INSERT INTO user(name, email, hashed_password) values (:name, :email, :hashed_password) """ From e97685e28a0862d0e337ceeab2d1a3915a74c447 Mon Sep 17 00:00:00 2001 From: seoyunje Date: Thu, 19 Nov 2026 18:53:47 +0900 Subject: [PATCH 3/9] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Switch=20logout=20e?= =?UTF-8?q?ndpoint=20from=20GET=20to=20POST?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/routes/auth.py | 2 +- client/src/components/Navbar.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/App/routes/auth.py b/App/routes/auth.py index 314f3bb3..12557273 100644 --- a/App/routes/auth.py +++ b/App/routes/auth.py @@ -73,7 +73,7 @@ async def login_user(request: Request, "status": "success" } -@router.get("/logout", status_code=status.HTTP_200_OK, response_class=JSONResponse, summary="로그아웃") +@router.post("/logout", status_code=status.HTTP_200_OK, response_class=JSONResponse, summary="로그아웃") async def logout_user(request: Request): request.state.session.clear() return { diff --git a/client/src/components/Navbar.js b/client/src/components/Navbar.js index ae6cdbaf..8b47f52b 100644 --- a/client/src/components/Navbar.js +++ b/client/src/components/Navbar.js @@ -31,7 +31,7 @@ const Navbar = ({ variant = 'dark', sessionUser, onLogout, links = [], logoutRed const handleLogoutClick = async () => { if (!window.confirm("로그아웃 하시겠습니까?")) return; try { - await axios.get('/auth/logout'); + await axios.post('/auth/logout'); if (onLogout) onLogout(); alert("성공적으로 로그아웃되었습니다."); navigate(logoutRedirect); From a3b9ec2d3e9bc31f88f0f7de7166f53f395686a3 Mon Sep 17 00:00:00 2001 From: seoyunje Date: Thu, 19 Nov 2026 19:53:30 +0900 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Require=20custom=20?= =?UTF-8?q?header=20on=20state-changing=20requests=20to=20block=20CSRF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/main.py | 4 ++++ App/utils/middleware.py | 25 +++++++++++++++++++++++-- client/src/index.js | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/App/main.py b/App/main.py index 6d3dab25..130b6cd3 100644 --- a/App/main.py +++ b/App/main.py @@ -26,6 +26,10 @@ # Register static files (images, videos) app.mount("/static", StaticFiles(directory="static"), name="static") +# CSRF defense: reject state-changing requests without the custom header +# (registered before CORS so CORS stays outside it and still handles preflight) +app.add_middleware(middleware.CSRFHeaderMiddleware) + # CORS Setup for cross-origin requests # FrontEnd: React, BackEnd: FastAPI origins_str = os.getenv("CORS_ALLOWED_ORIGINS") diff --git a/App/utils/middleware.py b/App/utils/middleware.py index 12b2bc68..a3b55c02 100644 --- a/App/utils/middleware.py +++ b/App/utils/middleware.py @@ -1,4 +1,5 @@ -from fastapi import Request, FastAPI +from fastapi import Request, FastAPI, status +from fastapi.responses import JSONResponse from starlette.middleware.base import BaseHTTPMiddleware import redis.asyncio as aioredis import uuid @@ -63,4 +64,24 @@ async def dispatch(self, request: Request, call_next): return response - \ No newline at end of file + +# CSRF defense: state-changing requests must carry a custom header. +# A cross-origin page can't add it without passing a CORS preflight, and requests +# without it (e.g. plain
POSTs) are rejected here. +CSRF_HEADER = "X-CSRF-Guard" +CSRF_PROTECTED_METHODS = {"POST", "PUT", "PATCH", "DELETE"} + + +class CSRFHeaderMiddleware(BaseHTTPMiddleware): + async def dispatch(self, request: Request, call_next): + if request.method in CSRF_PROTECTED_METHODS and CSRF_HEADER not in request.headers: + return JSONResponse( + content={ + "error_type": "http", + "status_code": status.HTTP_403_FORBIDDEN, + "title_message": "불편을 드려 죄송합니다", + "detail": "허용되지 않은 요청입니다. 페이지를 새로고침한 뒤 다시 시도해주세요.", + }, + status_code=status.HTTP_403_FORBIDDEN, + ) + return await call_next(request) diff --git a/client/src/index.js b/client/src/index.js index e86f3e12..b7a86666 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -9,6 +9,7 @@ import axios from 'axios'; axios.defaults.withCredentials = true; axios.defaults.baseURL = '/api'; axios.defaults.headers.common['ngrok-skip-browser-warning'] = 'true'; +axios.defaults.headers.common['X-CSRF-Guard'] = '1'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( From 23acb384e0168d7bd47ac2304f0e184f69f02400 Mon Sep 17 00:00:00 2001 From: seoyunje Date: Thu, 19 Nov 2026 20:16:28 +0900 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Always=20set=20Same?= =?UTF-8?q?Site=3DLax=20on=20session=20cookie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/utils/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App/utils/middleware.py b/App/utils/middleware.py index a3b55c02..6aac673c 100644 --- a/App/utils/middleware.py +++ b/App/utils/middleware.py @@ -52,7 +52,7 @@ async def dispatch(self, request: Request, call_next): or request.headers.get('x-forwarded-proto') == 'https') response.set_cookie(self.session_cookie, session_id, max_age=self.max_age, httponly=True, - secure=is_https, samesite='None' if is_https else 'Lax') + secure=is_https, samesite='Lax') await redis_client.setex(session_id, self.max_age, json.dumps(request.state.session)) else: From ef2b36ee9603069f05f7a2117effc3d84f70de48 Mon Sep 17 00:00:00 2001 From: seoyunje Date: Fri, 20 Nov 2026 19:23:45 +0900 Subject: [PATCH 6/9] =?UTF-8?q?=F0=9F=92=84=20Hide=20evidence=20buttons=20?= =?UTF-8?q?and=20trim=20guidance=20copy=20for=20REAL=20verdicts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/pages/AnalysisDetailPage.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/pages/AnalysisDetailPage.js b/client/src/pages/AnalysisDetailPage.js index e4db7e2c..d2adfc31 100644 --- a/client/src/pages/AnalysisDetailPage.js +++ b/client/src/pages/AnalysisDetailPage.js @@ -72,8 +72,8 @@ const VERDICT_COPY = { }, real: { badge: '실제 얼굴로 보여요', - image: '뚜렷한 위조 흔적이 발견되지 않았어요. 히트맵에서 모델이 본 부위를 확인할 수 있어요.', - video: '뚜렷한 위조 흔적이 발견되지 않았어요. 타임라인에서 구간별 결과를 확인할 수 있어요.', + image: '뚜렷한 위조 흔적이 발견되지 않았어요.', + video: '영상에서 뚜렷한 위조 흔적이 발견되지 않았어요.', }, unknown: { badge: '판정할 수 없어요', @@ -277,7 +277,7 @@ const AnalysisDetailPage = ({ sessionUser }) => { {VERDICT_COPY[verdictTone].badge}

{VERDICT_COPY[verdictTone][isVideo ? 'video' : 'image']}

- {mediaLoc && ( + {mediaLoc && verdictTone !== 'real' && (