개요
평소처럼 업무를 진행하며 회사 메일을 확인했는데,
`Exposed Git repository on host "~~~.com"` 와 같은 제목의 메일 한 통이 와있었다.
내용인 즉슨 해당 도메인에서 특정 url로 접속했을 때 git log가 그대로 노출된다는 경고 메일이었다.
repo-lookout
https://www.repo-lookout.org/
Repo Lookout
Use CommonCrawl and Tranco data to find publicly exposed Git repositories.
www.repo-lookout.org
repo-lookout은 Ko-fi에서 비영리 목적으로 만든 대규모 보안 스캐너로써 실수로 노출된 repository를 찾아 해당 기술 담당자에게 보고한다.
필자의 경우 잊고 있던 회사의 오래 전 프로젝트 중 하나에서 repo-lookout 관련 메일이 전달되었다.
Hello there,
Our security scanner Repo Lookout has found a likely vulnerability on a host for which you are listed as the contact!
Repo Lookout is a non-commercial project to find inadvertently publicly exposed source code repositories.
Details
The following URL was world-readable at the time of scanning (Jul 6 '23):
- https://~~~.com/.git/logs/HEAD
This allows (at least partial) access to the site's underlying source code repository!
For instance, the last 5 code commits have been:
- aaaaaaaa: ~~~~~~ 커밋
- bbbbbbbb: ~~~~~~ 커밋
- cccccccc: ~~~~~~ 커밋
- dddddddd: ~~~~~~ 커밋
- eeeeeeee: ~~~~~~ 커밋
Such access to the repository could give a malicious actor insight into the structure of the site (e.g. hidden functionality, critical bugs, or credentials to third-party services) and enable downstream attacks (e.g. data leakage, phishing, and extortion).
If this was not intended, we highly recommend to disable access to the source code repository!
Note that if the repository was intentionally made available, no action is required.
https://~~~.com/.git/logs/HEAD 링크에 접속하면 해당 repository의 git log가 그대로 노출되고 있었다.
해당 프로젝트는 php로 구성되어 git 연결을 통해 git push/pull 방식으로 배포가 이루어진 프로젝트였고 apache2로 웹 서버를 구성한 상태였다.
.git 폴더가 그대로 노출되고 있어 해당 git log에서 내 이메일을 확인하여 자동으로 나에게 메일 알림을 보낸 것으로 보였다.
대처 방안
공식 홈페이지에서 친절하게 대처 방안을 설명해주고 있어 그대로 따라하면 쉽게 .git 폴더의 내용을 노출시키지 않을 수 있다.
아래의 각 웹 서버에 맞는 방법으로 대처를 진행하도록 하자.
필자는 apache2에서 이슈를 해결하였다.
apache2
apache2.conf 파일에 아래 내용을 추가한다.
# /etc/apache2/apache2.conf
<DirectoryMatch "^/.*/\.git/">
Deny from all
</DirectoryMatch>
이후 웹 서버를 재시작
sudo service apache2 restart
nginx
nginx.conf 파일에 아래 내용을 추가한다.
# /etc/nginx/nginx.conf
location ~ /\.git {
deny all;
}
이후 웹 서버를 재시작
sudo service nginx restart
마무리
개인적으로 배포할 프로젝트 폴더에 git을 직접 연결하는 것은 좋지 않은 방식이라고 생각한다.
웬만하면 자동화 배포를 구성하여 빌드된 산출물이나 배포할 내용을 직접 전달하는 방식을 택하도록 하자.
'Setting' 카테고리의 다른 글
JMeter 설치하기 (0) | 2023.07.31 |
---|---|
[React] localhost https 설정하기 (0) | 2023.07.12 |
http를 https로 리다이렉트하는 여러가지 방법 (0) | 2023.06.08 |
hosts 파일 다루기 (0) | 2023.05.24 |
Bitbucket SSH 설정하기 (0) | 2023.05.19 |