그저 내가 되었고

🗃️MySQL:: Brute Force(무차별 대입 공격) 대응 방법 본문

카테고리 없음

🗃️MySQL:: Brute Force(무차별 대입 공격) 대응 방법

hyuunii 2023. 7. 13. 13:13

NCP에서 Cloud DB for MySQL 서비스를 이용중인데 아래와 같은 보안 알림이 떴다.

Brute Force란 무엇이며, 어떻게 대응할 수 있을지 정리해보았다.
 

 

 

Brute Force(무차별 대입 공격)이란?

브루트(Brute) : 무식한     +     포스(Force) : 
조합 가능한 모든 문자열을 하나씩 대입해 보는 방식으로 암호를 해독하는 방법이다.
 
즉, 발생할 수 있는 모든 경우를 무식하게 탐색한다는 뜻이다.
전체를 탐색한다는 의미에서 전체 탐색, 완전 탐색이라고도 한다.
 
말 그대로 '될 때까지 하면 된다(..)'의 정신으로 모든 범위를 탐색하기 때문에,
시간이야 무진장 오래 걸릴지언정 언젠가는 무조건 정답을 찾을 수 있다.
 
 
 
 
 
 
 

MySQL Brute Force 대응 방법

암호라는건 어찌되었건 하나 이상 존재하고, 찾을 때까지 찾으면 결국엔 찾아진다.
그러므로 아래와 같은 방법을 섞어 사용하여 찾기 최대한 어렵도록 하는것이 최선의 방법이다.
 
- 복잡하고 긴 암호 사용
- 주기적으로 암호 변경
- 지정된 로그인 횟수 초과시 계정 잠금 설정
- 지정된 ip만 로그인 가능하도록 설정
등등
 
 
이 중 
복잡하고 긴 암호 사용 & 지정된 로그인 횟수 초과시 계정 잠금 설정
이를 어떻게 챙길지, 글쓴이가 시도한 방법을 서술한다.
 
 
 
 
1. 복잡하고 긴 암호 사용
: 최소 10자 이상, [대소문자/숫자/특수문자] 중 두 개 이상 사용
 
아래의 사이트에서 내 암호의 안전도를 체크할 수 있다.
https://www.security.org/how-secure-is-my-password/

 

How Secure Is My Password? | Password Strength Checker

Data breaches and identity theft are on the rise, and the cause is often compromised passwords. After stealing credentials, cybercriminals can use passwords to

www.security.org

 
 

 
암호의 안전도를 체크해보니
ㅋㅋ... 꽤나 풀기 힘든가보다.
 
 
 
 
 
2. 지정된 로그인 횟수 초과시 계정 잠금 설정
MySQL의 Password Management 정책이 잘 되어 있다. 이를 활용하자.
 
p.s.
사실 원래 의도한 바는 db의 host 자체에 대해서 계정 잠금을 설정하는것이었다.
그런데 거의 하루 넘도록 구글링을 열심히 해보았는데도 그런것은 찾지 못했다.
대신 해당 db의 user 목록 전체에 대해서 각각 lock을 걸어줄 수 있었다.
 
 
1) 먼저 아래의 쿼리로 사용자 목록을 확인하자

use mysql;
select user, host from user;

 
2) 예컨대 아래와 같은 계정이 있다고 할 때

+------------------+-----------+
| user             | host      |
+------------------+-----------+
| root             | %         |
| user01           | localhost |
+------------------+-----------+

 
3) 아래의 쿼리를 통해서 각각 로그인 시도 4회 실패시 이틀간의 계정 잠금을 활성화할 수 있다.

ALTER USER 'root'@'%' FAILED_LOGIN_ATTEMPTS 4 PASSWORD_LOCK_TIME 2;

ALTER USER 'user01'@'localhost' FAILED_LOGIN_ATTEMPTS 4 PASSWORD_LOCK_TIME 2;

* ALTER USER : 계정의 정보를 수정하는 구문.
ㄴThe ALTER USER statement modifies MySQL accounts. It enables authentication, role, SSL/TLS, resource-limit, password-management, comment, and attribute properties to be modified for existing accounts. It can also be used to lock and unlock accounts.
 
* FAILED_LOGIN_ATTEMPTS : 몇 회 실패시 계정 잠글지. 이는 해당 횟수만큼 '연속적'으로 실패여야 한다.
ㄴFor temporary account locking to occur, password failures must be consecutive. Any successful login that occurs prior to reaching the FAILED_LOGIN_ATTEMPTS value for failed logins causes failure counting to reset. For example, if FAILED_LOGIN_ATTEMPTS is 4 and three consecutive password failures have occurred, one more failure is necessary for locking to begin. But if the next login succeeds, failed-login counting for the account is reset so that four consecutive failures are again required for locking.
 
* PASSWORD_LOCK_TIME : 계정 잠글 기간. day가 기준이므로 1시간은 1/24, 10분은 10/1440이다.
ㄴOnce temporary locking begins, successful login cannot occur even with the correct password until either the lock duration has passed or the account is unlocked by one of the account-reset methods listed in the following discussion.
 
 
 
더 자세한 내용은 아래의 공식 문서를 참조하자.
https://dev.mysql.com/doc/refman/8.0/en/password-management.html