
Solidity 어셈블리 반환 데이터 크기 혼동에 대한 교육용 PoC; 취약한 컨트랙트, 익스플로잇 시뮬레이션, 안전한 ABI 디코딩을 위한 완화 지침을 포함합니다.
// ReturnSizeConfusion.sol
contract Victim {
function callExternal(address target) external returns (bytes memory) {
(bool success, bytes memory ret) = target.call(abi.encodeWithSignature("someFunc()"));
require(success, "call failed");
// Vulnerability: assumes ret is at least 32 bytes, but could be empty
uint256 value;
assembly {
value := mload(add(ret, 32))
}
return ret;
}
}
Solidity 계약이 인라인 어셈블리를 사용하여 반환 값을 읽지만 반환 데이터 길이가 충분한지 검증하지 않습니다. 공격자가 빈 데이터를 반환하여 어셈블리가 임의의 스택 데이터를 읽도록 만들 수 있으며, 이로 인해 메모리 손상 또는 보안 우회가 발생할 수 있습니다.
취약한 계약과 빈 응답을 반환하는 공격자 계약을 배포합니다. mload는 오래된 데이터를 읽습니다.
ret의 길이를 확인하십시오.abi.decode)를 사용하십시오.git clone https://github.com/yourorg/CVE-2026-23008.git
cd CVE-2026-23008
# Use Foundry to test