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

fix: 로그인 시 Open Redirect 취약점 수정 #566

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions bbs/#.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from core.template import UserTemplates
from lib.common import session_member_key
from lib.dependency.dependencies import set_current_connect
from lib.dependency.dependencies import set_current_connect, validate_login_url
from lib.member import is_super_admin
from lib.social import providers
from lib.social.social import SocialProvider, oauth
Expand Down Expand Up @@ -36,10 +36,10 @@ async def login_form(
async def login(
request: Request,
member_service: Annotated[MemberService, Depends()],
url: Annotated[str, Depends(validate_login_url)],
mb_id: str = Form(...),
mb_password: str = Form(...),
auto_login: bool = Form(default=False),
url: str = Form(default="/")
):
"""로그인 폼화면에서 로그인"""
member = member_service.authenticate_member(mb_id, mb_password)
Expand Down
14 changes: 13 additions & 1 deletion lib/dependency/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,16 @@ async def set_current_connect(

except ProgrammingError as e:
print(e)



def validate_login_url(url: str = Form(default="/")):
"""
로그인할 때 url을 검사하는 함수
"""
allow_urls = []

if (url
and not url.startswith("/")
and url not in allow_urls):
raise AlertException("올바르지 않은 URL입니다.", 400)
return url