Open
Conversation
500e363 to
032c95d
Compare
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.
과제 제출 정보
주차: Week 03
과제 유형:
구현 내용
quiz-03-solution.md에서 EVM 결정론, Storage/Memory/Stack 비용, CEI, tx.origin 취약점, ReentrancyGuard 비교, 재진입 다이어그램 해석 문제를 정리했습니다.배운 점 (What I Learned)
이번 주에 배운 것 (2-3가지)
어려웠던 점과 해결 방법
어려웠던 점:
초기에 CEI 패턴만 적용해
withdraw()를 구현했을 때, 재진입 시 내부 호출에서 발생한revert가 공격자receive()를 거쳐 바깥call까지 전파되었습니다.그 결과
success가false가 되어"Transfer failed"로 정상 출금도 함께 취소되는 일이 벌어졌습니다.silent return방식(if (_locked) return;)을 사용하면 된다는 것을 배웠지만, 실무에서 널리 권장되는 패턴은 아니라고 하여 실무에서 자주 쓰이는 방법으로 다시 구현하였습니다해결 방법:
최종적으로 업계 표준인
nonReentrantmodifier명시적 revert를 채택했습니다.재진입 시도를
require(!_locked, "ReentrancyGuard: reentrant call")로 명확히 차단하는 방식이며, OpenZeppelinReentrancyGuard와 동일한 접근입니다.현재 테스트의
Attacker컨트랙트는revert를 상위 호출로 전파하는 구조라 일부 재진입 테스트와 충돌이 있었지만, 보안 관점에서 재진입 자체는 확실히 차단되므로 이 구현을 최종 선택했습니다.처음에는
if (_locked) return;처럼 조용히 넘기는 방식을 써봤는데, 실무에서 표준적으로 많이 쓰는 방식이 아니라고 하여 대신 OpenZeppelin에서 쓰는 방식처럼nonReentrant를 사용해서 명시적 revert로 재진입을 막는 방향으로 다시 구현하였습니다테스트 일부와 충돌하는 부분은 있었지만, 보안 관점에서는 재진입 자체를 명확하게 차단하는 게 더 중요하다고 판단해서 이 구현을 선택하였습니다.
질문 사항
-nonReentrant(revert)를 쓰면 공격자가 자기 돈을 못 돌려받고, silent return을 쓰면 자기 돈은 돌려받는데, 어떤 쪽으로 구현하는게 올바른 방향인가요.??
체크리스트
테스트
forge build성공forge test모든 테스트 통과->VaultSecure 10/12 통과제출 규칙
{username}/week-{XX}형식.env파일이 커밋에 포함되지 않음