자동 로그인 key를 예측하기 어렵도록 변경#1359
Merged
1 commit merged intoMay 19, 2015
Merged
Conversation
Contributor
|
https://travis-ci.org/xpressengine/xe-core/builds/56375685 php5.4에서만 에러나는..이상한 형상..? |
Contributor
Author
|
@qw5414 PHP 5.4 멀쩡한데요? Travis CI가 잠시 버벅거린 듯 ㅠ 보안패치이긴 하지만, 공격 대상 계정의 비번을 이미 알고 있거나 DB를 탈취한 후에야 사용할 수 있는 취약점이므로 당장 급한 문제는 아닙니다. 테스트가 더 필요하다면 느긋하게 테스트하세요. |
Contributor
|
@kijin 아하 그런 것 같아요. |
Closed
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
현재는 자동 로그인 key를 생성할 때 회원 아이디(메일주소), 비번 해시, 브라우저 user-agent만을 기준으로 하고 있어서, 다른 경로로 회원 DB를 탈취한 공격자가 비번 해시를 뚫을 필요도 없이 몇 가지 일반적인 브라우저 user-agent만 시도해 보면 유효한 자동 로그인 key를 생성할 수 있습니다.
XE 1.8부터 회원 DB 탈취에 대비하여 비번 해시 알고리듬을 대폭 강화한 것이 무용지물이 될 수도 있다는 말이죠. (단, 해당 회원이 자동 로그인을 사용하고 있는 경우에만 공격이 가능합니다.)
실제로 같은 브라우저에서 같은 계정으로 자동 로그인을 여러 번 해보면 항상 똑같은 key가 생성되는 것을 볼 수 있습니다.
해결책
자동 로그인 key를 생성할 때 난수를 포함하고, 기존에 사용하던 아이디, 비번 해시, 브라우저 user-agent 값은 이 난수를 사용한 HMAC으로 만들어 넣습니다. 난수 32자와 HMAC 32자를 합친 64자를 자동 로그인 key로 사용합니다. 다행히
varchar(80)으로 되어 있어서 자리는 넉넉하네요.자동 로그인을 허락할지 결정할 때는 우선 key가 DB에 존재하는지 확인한 후, 난수와 HMAC, 현재의 user-agent 값이 서로 들어맞는지 검사합니다.
같은 브라우저에서 같은 계정으로 자동 로그인을 여러 번 하더라도 매번 다른 key가 생성됩니다.
#987 PC/모바일 다중로그인 문제는 다루지 않고, key 생성 및 확인 루틴만 고쳤습니다.