Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Redis password 설정 #34

Merged
merged 1 commit into from
Nov 21, 2022
Merged

Redis password 설정 #34

merged 1 commit into from
Nov 21, 2022

Conversation

leesungbin
Copy link
Member

@leesungbin leesungbin commented Nov 17, 2022

개요

redis가 외부로부터 flush-all을 당하고 해커가 원하는 값이 redis에 세팅 되는 현상을 발견하여 redis에 비밀번호 설정

  • 세팅해놨던 키들이 지속적으로 삭제(flush-all)되는 현상을 발견
  • Redis log를 확인하니, DB가 save되는 시점에 flush-all 되는 현상을 확인
  • Redis container에서 keys * 를 실행해보니, backup1, backup2, backup3, backup4 가 cron 명령어 형태로 세팅됨
    • dump.rdb 파일을 확인했을 때, 설정하지 않은 key들이 설정되어있음을 확인
  • redis에 비밀번호를 설정해놓지 않아 해킹당했다는 여러 글들을 확인하면서 원인을 파악함.

원인

  • Server 생성시 이전 프로젝트 때 생성해놨던 ACG를 그대로 사용하면서 redis에 사용하고 있던 포트가 public하게 열려있는 상태임을 인지하지 못한 상태였음.
  • Redis에 비밀번호를 설정해놓지 않아서 누구나 REDIS_PORT만 알면 redis에 접속 가능한 상태였음.

작업사항

  • Redis 비밀번호 설정 및 nest application에서 redis 연결시 환경변수로 비밀번호 전달
  • Redis의 60초마다 1000개의 key가 변경되었는지 검사하여 save(dump) 함.
  • Redis의 loglevel은 기본(notice)으로 함.
    • loglevel 종류
    # debug (a lot of information, useful for development/testing)
    # verbose (many rarely useful info, but not a mess like the debug level)
    # notice (moderately verbose, what you want in production probably)
    # warning (only very important / critical messages are logged)
    

리뷰 요청사항

  • 백엔드 로컬 개발환경의 env 파일에 REDIS_PASSWORD를 추가했을 때, application이 정상작동하는가
  • 배포된 환경의 redis에 비밀번호를 입력해야만 접속할 수 있는가

redis가 외부로부터 flush-all을 당하고 해커가 원하는 값이 redis에 세팅되는 것을 방지

fix #17
@leesungbin leesungbin linked an issue Nov 17, 2022 that may be closed by this pull request
@leesungbin leesungbin marked this pull request as ready for review November 17, 2022 14:18
@github-actions github-actions bot requested review from Palwol and yeynii November 17, 2022 14:19
Copy link
Collaborator

@Palwol Palwol left a comment

Choose a reason for hiding this comment

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

원인을 찾아서 다행입니다. 환경변수에 로컬 redis password 추가하겠습니다.

Copy link
Member

@yeynii yeynii left a comment

Choose a reason for hiding this comment

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

보안의 중요성을 체감하게 되네요

@leesungbin leesungbin merged commit f37c94b into dev Nov 21, 2022
@leesungbin leesungbin deleted the feature/docker-compose-auth branch November 21, 2022 04:09
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE] 개발 서버 Redis 해킹당한 현상
3 participants