# Solidity Empty Byte Array Copy Bug **Published by:** [高可用匿名性学习笔记](https://paragraph.com/@0x4ca146039c567a8cbfde83c23a515b587d9be469/) **Published on:** 2022-10-24 **URL:** https://paragraph.com/@0x4ca146039c567a8cbfde83c23a515b587d9be469/solidity-empty-byte-array-copy-bug ## Content 2020年10月4日, John Toman 发现该漏洞。 影响范围 version < 0.7.4, 中危。 漏洞简述 依次执行以下三个操作将造成,bytes、string被非零值初始化。 从 memory/calldata copy 空的bytes/string 到 storage 中 对该storage中的 bytes/string 做 .push() 操作,使length增长。 在向新空间写入前,直接读取 举例如下: contract C { bytes data; function f() public returns (bytes memory) { uint[2] memory x; x[0] = type(uint).max; // 先在memory中存点别的东西 bytes memory t; data = t; data.push(); return data; // 这里会越界读到 x 的值,返回值会是 0xff 而非 0x00 } } ## Publication Information - [高可用匿名性学习笔记](https://paragraph.com/@0x4ca146039c567a8cbfde83c23a515b587d9be469/): Publication homepage - [All Posts](https://paragraph.com/@0x4ca146039c567a8cbfde83c23a515b587d9be469/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@0x4ca146039c567a8cbfde83c23a515b587d9be469): Subscribe to updates - [Twitter](https://twitter.com/WIZ6UwegOD40Ccj): Follow on Twitter