code4rena-2023-09-centrifuge-m08
[M-08] The Restriction Manager does not completely implement ERC1404 which leads to accounts that are supposed to be restricted actually having access to do with their tokens as they see fit
Summary
ERC1404 구현에서, 토큰을 수신할 때만 멤버인지 확인하고 발신할 때는 확인하지 않았다. 따라서 블락된 유저도 토큰을 발신할 수 있다.
Keyword
erc1404, access control
Vulnerability
ERC-1404는 ERC20에 기능을 추가한 것으로, 토큰을 이동하는 자격을 제한하는 기능을 제공한다.
다음은 ERC-1404 인터페이스이다. detectTransferRestriction 함수와 messageForTransferRestriction 함수가 있다.
contract ERC1404 is ERC20 {
function detectTransferRestriction (address from, address to, uint256 value) public view returns (uint8);
function messageForTransferRestriction (uint8 restrictionCode) public view returns (string);
}detectTransferRestriction: 토큰 이동을 제한하는 데 사용하는 함수. 토큰 수신자가 허용 리스트에 있는지 확인하거나, 발신자의 토큰이 락업 상태인지 등의 확인하는 로직을 구현하면 된다.messageForTransferRestriction: 토큰 이동이 제한되었을 때, 에러코드를 사람이 읽을 수 있는 설명으로 변환하는 함수.
RestrictionManager 컨트랙트에서는 from(토큰 발신자)을 확인하지 않는다. 오로지 to(토큰 수신자)만 확인하고 있다. 따라서 블락리스트에 오른 사용자가 여전히 송금을 할 수 있다.
function detectTransferRestriction(address from, address to, uint256 value) public view returns (uint8) {
@> if (!hasMember(to)) {
return DESTINATION_NOT_A_MEMBER_RESTRICTION_CODE;
}
return SUCCESS_CODE;
}Impact
블락된 유저가 여전히 토큰을 송신할 수 있다.
Mitigation
detectTransferRestriction 함수에서 토큰 발신자(from)도 확인하도록 수정한다.
tags: bughunting, centrifuge, smart contract, solidity, erc1404, access control vulnerability, severity medium