Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ jobs:
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
echo "${{ secrets.GCP_KEY_BASE64 }}" | base64 -d > /home/ubuntu/linku-key.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

GCP 자격증명 파일의 권한 제한 및 정리 필요.

Base64로 인코딩된 GCP 키를 디코딩할 때 다음 보안 문제가 있습니다:

  1. 파일 권한 미설정: 생성된 JSON 파일이 기본 권한으로 생성되어 호스트의 다른 사용자가 읽을 수 있습니다.
  2. 영구 저장 문제: 디코딩된 자격증명 파일이 배포 후에도 호스트에 남아있어 보안 위험을 초래합니다.
  3. 오류 처리 부재: base64 디코딩 실패 시 작업이 계속 진행되어 잘못된 자격증명으로 컨테이너가 실행될 수 있습니다.

다음과 같이 수정하는 것을 권장합니다:

  script: |
+   set -e  # 오류 발생 시 즉시 종료
-   echo "${{ secrets.GCP_KEY_BASE64 }}" | base64 -d > /home/ubuntu/linku-key.json
+   echo "${{ secrets.GCP_KEY_BASE64 }}" | base64 -d > /home/ubuntu/linku-key.json
+   chmod 600 /home/ubuntu/linku-key.json
    sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}

배포 후 정리를 위해 Docker 컨테이너 제거 이후에 다음을 추가하세요:

    sudo docker image prune -a -f
+   rm -f /home/ubuntu/linku-key.json

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
.github/workflows/gradle.yml around line 66: the workflow decodes the base64 GCP
key to a JSON file without setting restrictive permissions, without checking for
decode errors, and without ensuring the file is removed after use; change the
flow to decode into a secure temporary file (use mktemp), immediately set file
mode to 600, fail the job if base64 decoding or file creation fails (check exit
status and exit non‑zero), use the temporary file only for the docker/build
steps that need it, and ensure the file is removed (or securely shredded) after
use — ideally via a trap or explicit cleanup step after the container is removed
so no plaintext credential remains on the runner.

sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
sudo docker pull ${{ secrets.DOCKER_REPO_NAME }}:latest
sudo docker stop linku || true
sudo docker rm linku || true
sudo docker run -d --name linku --log-driver=syslog -p 8080:8080 \
-v /home/ubuntu/linku-key.json:/app/linku-key.json \
-e GOOGLE_APPLICATION_CREDENTIALS=/app/linku-key.json \
-e TZ=Asia/Seoul \
-e SPRING_PROFILES_ACTIVE= \
${{ secrets.DOCKER_REPO_NAME }}:latest
Expand Down