🇰🇷 한글 설명
Gitea의 API 엔드포인트가 미디어 파일을 반환할 때 적절한 Content-Type 및 Disposition 헤더를 설정하지 않는 취약점입니다. 이로 인해 저장소에 커밋된 HTML 파일이 브라우저에서 직접 렌더링될 수 있으며, 공격자는 이를 통해 피해자의 세션에서 자바스크립트를 실행할 수 있습니다.
💡 쉬운 설명
저장소에 악성 코드가 담긴 HTML 파일을 올린 뒤, 다른 사용자가 해당 링크를 클릭하게 유도하여 계정을 탈취할 수 있는 보안 약점입니다. 브라우저가 파일을 단순 다운로드가 아닌 웹페이지로 잘못 인식하여 발생하는 문제입니다.
🇺🇸 원문 (English)
The Gitea API endpoint `GET /api/v1/repos/{owner}/{repo}/media/{filepath}` wrote files of up to 1 KiB that are stored directly in Git, not in LFS, to the response without the content type and disposition headers Gitea uses for user content. An HTML file committed to a repository was therefore rendered by the browser on the Gitea origin. A user who can push to a repository could run JavaScript in the session of a victim who opens the media URL and act with the victim's permissions.
📍 영향받는 시스템
Gitea (해당 취약점이 해결되기 전 버전)
⚔️ 공격 벡터
저장소에 권한이 있는 사용자가 악성 HTML 파일을 푸시한 후, 피해자에게 해당 미디어 파일의 API URL을 클릭하도록 유도함
🛡️ 대응 방법
Gitea를 최신 보안 패치가 적용된 버전으로 업데이트하거나, 미디어 파일 반환 시 적절한 HTTP 헤더가 설정되도록 수정해야 합니다.
🔧 검증 코드
응답 헤더에 Content-Type이 text/html로 나타나거나 Content-Disposition이 attachment로 설정되어 있지 않으면 취약한 상태입니다.
curl -I 'http://<gitea-url>/api/v1/repos/<owner>/<repo>/media/<html-file-path>' | grep -E 'Content-Type|Content-Disposition'