Conversation
Summary of ChangesHello @1000hyehyang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 캠페인 지원 및 제안과 관련된 시스템 메시지를 보낼 때, 해당 메시지가 전송될 채팅방이 아직 생성되지 않은 경우 자동으로 채팅방을 생성하도록 하여 시스템의 견고성을 높입니다. 이는 메시지 전송 실패를 방지하고 사용자 경험을 개선하는 데 기여합니다. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This PR adds logic to create chat rooms when they don't exist. However, a security audit identified two medium-severity Broken Access Control vulnerabilities. These issues stem from newly introduced helper methods that incorrectly determine the actor's ID when calling createOrGetRoom, leading to authorization checks being performed against the wrong user identity. For CampaignApplySentEvent, the creatorUserId should always be the actor, and for CampaignProposalSentEvent, the actor needs to be dynamically determined based on proposalDirection. Please refer to the specific comments for refactoring details.
|
|
||
| Long roomId = roomIdOpt.get(); | ||
| // 채팅방이 없으면 생성 | ||
| Long roomId = ensureRoomAndGetId(event.brandUserId(), event.creatorUserId()); |
There was a problem hiding this comment.
ensureRoomAndGetId 메소드가 올바른 행위자(actor)로 채팅방을 생성하려면 proposalDirection 정보가 필요합니다. event.proposalDirection()을 메소드에 전달해주세요.
| Long roomId = ensureRoomAndGetId(event.brandUserId(), event.creatorUserId()); | |
| Long roomId = ensureRoomAndGetId(event.brandUserId(), event.creatorUserId(), event.proposalDirection()); |
| private Long ensureRoomAndGetId(Long brandUserId, Long creatorUserId) { | ||
| return chatRoomCommandService | ||
| .createOrGetRoom(brandUserId, brandUserId, creatorUserId) | ||
| .roomId(); | ||
| } |
There was a problem hiding this comment.
This ensureRoomAndGetId method has a logical flaw leading to a Broken Access Control vulnerability. It incorrectly passes brandUserId as the actor's ID to createOrGetRoom. In the context of a CampaignApplySentEvent, the creatorUserId is the actual actor, meaning authorization checks are performed against the wrong user identity. This should be corrected to pass creatorUserId as the actor.
| private Long ensureRoomAndGetId(Long brandUserId, Long creatorUserId) { | |
| return chatRoomCommandService | |
| .createOrGetRoom(brandUserId, brandUserId, creatorUserId) | |
| .roomId(); | |
| } | |
| private Long ensureRoomAndGetId(Long brandUserId, Long creatorUserId) { | |
| return chatRoomCommandService | |
| .createOrGetRoom(creatorUserId, brandUserId, creatorUserId) | |
| .roomId(); | |
| } |
| private Long ensureRoomAndGetId(Long brandUserId, Long creatorUserId) { | ||
| return chatRoomCommandService | ||
| .createOrGetRoom(brandUserId, brandUserId, creatorUserId) | ||
| .roomId(); | ||
| } |
There was a problem hiding this comment.
This ensureRoomAndGetId method incorrectly hardcodes brandUserId as the actor for createOrGetRoom, leading to a Broken Access Control vulnerability. For a CampaignProposalSentEvent, the actor should be dynamically determined based on the proposalDirection. The current implementation performs authorization using the wrong user identity when the creator sends a proposal. The proposalDirection should be used to correctly identify the actor.
| private Long ensureRoomAndGetId(Long brandUserId, Long creatorUserId) { | |
| return chatRoomCommandService | |
| .createOrGetRoom(brandUserId, brandUserId, creatorUserId) | |
| .roomId(); | |
| } | |
| private Long ensureRoomAndGetId(Long brandUserId, Long creatorUserId, ProposalDirection direction) { | |
| Long actorId = ProposalDirection.CREATOR_TO_BRAND.equals(direction) ? creatorUserId : brandUserId; | |
| return chatRoomCommandService | |
| .createOrGetRoom(actorId, brandUserId, creatorUserId) | |
| .roomId(); | |
| } |
Summary
Changes
Type of Change
Related Issues
참고 사항