日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Integer overflow, simple but not easy

發(fā)布時(shí)間:2025/3/15 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Integer overflow, simple but not easy 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Our analysis and further investigation on proxyOverflow (CVE-2018–10376) and batchOverflow (CVE-2018–10299) vulnerabilities.?Verichains Lab?has performed a scan on all Ethereum smart contracts with above 100 tx and confirmed that the bugs affected quite a number of smart contracts.

Integer overflow

This section is just definitions, can be skipped for people already know about it.

In?computer programming, an?integer overflow?occurs when an?arithmeticoperation attempts to create a numeric value that is outside of the range that can be represented with a given number of bits?—?either larger than the maximum or lower than the minimum representable value. - wikipedia.org

In computer, normal integer operations work well if nothing is out of bound,?1 + 1 = 2,?2 + 2 = 4,?4 + 4 = 8,?…,?64 + 64 = 128,?…

wait, that simple addition?does not work?with computer, if the last addition operation is performed using?8-bit signed integer arithmetics, the result is?-128!

64 + 64 using signed 8-bit integer?addition

This seems wrong but actually it’s the way integers work in computer. All operations of fixed width integers are?truncated. If a number is stored as 8 bit signed integer, its value must be within the range?-128 to 127, inclusively, else the value will be?truncated?into that range, or in another way, only lowest bits are kept for the operation results.

Binary expression of 8 bit signed integers for values from 0 to 127 are:

0: 00000000 | 1: 00000001 | 2: 00000010 | 3: 00000011 ... 124: 01111100 | 125: 01111101 | 126: 01111110 | 127: 01111111

Negative numbers are expressed using?two’s complement. Values from -128 to -1 are:

-128: 10000000 | -127: 10000001 | -126: 10000010 | -125: 10000011 ...-4: 11111100 | -3: 11111101 | -2: 11111110 | -1: 11111111

The number 64 is encoded as?01000000?in base 2,?64 + 64?is?0100000 + 01000000 = 10000000, it’s actually?128?but it’s out of the range above encoding can cover, so it’s?truncated?and mapped to-128?as in the above table!

Furthermore, in 8-bit unsigned arithmetics,?128 + 128 = 0. More formally let’s say we store result ofa + b?into variable?r?which encoded using?n-bit unsigned integer, only the following equation holds:

a + b ≡ r mod?2^n

CVE-2018–10376:?proxyOverflow

An integer overflow in the transferProxy function of a smart contract implementation for SmartMesh (aka SMT), an Ethereum ERC20 token, allows attackers to accomplish an unauthorized increase of digital assets via crafted _fee and _value parameters, as exploited in the wild in April 2018, aka the “proxyOverflow” issue.method?transferProxy?of?MESH?contract

This method already have integer overflow in mind (coded at?line 10?and?line 11?to detect overflow on post-update balance check) but the pre-update balance check at line 4 did not handle addition-overflow of?_feeMesh + _value, both these 2 variables are directly controlled by user-input as parameters. With integer overflow each of these variables can be large enough and their sum (truncated with integer overflow) become small enough to satisfy the check, which has been used to exploit the contract at?block 5497602:

Function: transferProxy(address _from, address _to, uint256 _value, uint256 _fee, uint8 _v, bytes32 _r, bytes32 _s)MethodID: 0xeb502d45 [0]: 00000000000000000000000024e62761adad4e64be580efa6180282004bae866 [1]: 00000000000000000000000024e62761adad4e64be580efa6180282004bae866 [2]: 8fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff [3]: 7000000000000000000000000000000000000000000000000000000000000001 [4]: 000000000000000000000000000000000000000000000000000000000000001b [5]: aebbb9bbb393b69eabc44fea38860cf7fbf274d179b37a1d6444569b734f17f3 [6]: 16565f08cb904fe6c00ff33618acc13ca6bd269150353648851525beb9d048ec

With the above input,?_value?is?8fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff,?_feeis?7000000000000000000000000000000000000000000000000000000000000001, which sums up to?0?in 256 bit unsigned integer.

CVE-2018–10299: batchOverflow

An integer overflow in the batchTransfer function of a smart contract implementation for Beauty Ecosystem Coin (BEC), the Ethereum ERC20 token used in the Beauty Chain economic system, allows attackers to accomplish an unauthorized increase of digital assets by providing two _receivers arguments in conjunction with a large _value argument, as exploited in the wild in April 2018, aka the “batchOverflow” issue.method?batchTransfer?of?MTC?contract.

This time the overflow is caused by multiplication on line 3, with large enough?_value?and?cnt, we can generate small enough?amount?and exploit the contract, like in?block 5512547:

Function: batchTransfer(address[] _receivers, uint256 _value)MethodID: 0x83f12fec [0]: 0000000000000000000000000000000000000000000000000000000000000040 [1]: 8000000000000000000000000000000000000000000000000000000000000000 [2]: 0000000000000000000000000000000000000000000000000000000000000002 [3]: 0000000000000000000000004473c6396eba3d737f953a8849b0f4296be8c3e7 [4]: 00000000000000000000000066f471fd1c471bb3ee15d81a3cea4a7f21282355

The above input sent?_value?as?8000000000000000000000000000000000000000000000000000000000000000?and the?_receivers?as array of length 2, which result in?amount = 8000000000000000000000000000000000000000000000000000000000000000 * 2 = 0.

Affected contracts

Using our internal tool, Verichains Lab has performed a scan on all Ethereum smart contracts with above 100 tx and found that the bugs affected quite a number of smart contracts.

batchTransfer

CryptoBotsBattle (CBTB)

UPCToken (UPCT),?UPCToken (UPC),?MTC (MTC),?BeautyChain (BEC)

transferProxy

MeshBox (MESH),?M2C Mesh Network (MTC),?M2C Mesh Network (mesh),?SmartMesh (SMT),?UG Token (UGT)

We also found a contract with similar vulnerability but luckily the method can only be called by admin.

Beercoin (

總結(jié)

以上是生活随笔為你收集整理的Integer overflow, simple but not easy的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 99999视频| 男人天堂视频网站 | 黄色片在线看 | 国产亲伦免费视频播放 | 狠狠爱免费视频 | 日韩精品一区二区不卡 | 艳妇av | 日韩操操操 | 超碰人人爱人人 | 国产aⅴ一区二区三区 | 国产色视频 | 成人免费小视频 | youjizzcom日本 | 天天看夜夜爽 | 丁香婷婷综合激情五月色 | 理论片在线观看理伦片 | 国产精品久久久久国产a级 国产一区二区在线播放 | 亚洲国产日韩在线观看 | 久久国产免费看 | 99思思| 亚洲成人精品一区 | 亚洲欧美第一 | 男人的天堂黄色 | 韩国性经典xxxxhd | 欧美性大战久久久久久久 | 精品丰满少妇一区二区三区 | 性五月天| 亚洲乱码国产乱码精品天美传媒 | 伦理av在线 | 日本一二三不卡视频 | 日本精品久久久久久久 | 国产免费高清视频 | 人人爱人人插 | 狠狠干2024 | 亚洲精品四区 | 国产尤物视频在线 | 狠狠操导航 | 樱空桃在线 | 日韩av一级| 国产精品毛片一区视频播 | 欧美久久99 | 日韩av影音先锋 | 99成人 | 高清无码视频直接看 | 免费看黄色大片 | 18av在线播放 | 免费在线观看黄色av | 亚洲天堂不卡 | 日韩中文字幕一区二区三区四区 | 日韩一区二区三区视频 | 亚洲AV无码精品国产 | 青青草国产精品视频 | 日本xxx在线播放 | www.男女| 日本激情网站 | 国产精品嫩 | 国产男女无套免费网站 | 国产精品入口麻豆 | 69视频一区二区 | 免费福利影院 | 国产精品一二三四 | 日本一级大毛片a一 | av操操| 在线观看欧美日韩视频 | 91禁在线观看 | 国产精品一区二区三区在线 | 人人爱人人搞 | 美女黄色一级片 | 欧美黄色a视频 | 黄色a级片在线观看 | 在线视频午夜 | 成人免费观看网址 | 小柔的淫辱日记(h | 日本妈妈9 | 动漫美女被吸奶 | 天堂中文字幕免费一区 | 亚洲av永久无码精品一区二区国产 | 日韩欧美成人免费视频 | 波多野结衣亚洲 | 天天插天天狠天天透 | 91色| 亚洲成av人片在线观看无 | 中文字幕乱码视频 | 中国挤奶哺乳午夜片 | 国产怡红院 | 精品人妻二区中文字幕 | 午夜精品久久久久久久久久 | 国产精品免费无码 | 日日夜夜操操操 | 日韩a√ | 亚洲av片一区二区三区 | 久久99婷婷 | 女生的胸无遮挡 | 69影院在线观看 | 青青草在线播放 | 色婷婷久久综合 | 精品人妻一区二区三区蜜桃 | 麻豆视频免费 | 成人午夜剧场视频网站 |