Move language reference security vulnerabilities: integer overflow risks and prevention recommendations

robot
Abstract generation in progress

In-depth Analysis of Move Language Reference Security Vulnerabilities

Recently, during our in-depth research on Aptos Moveevm, we discovered a new integer overflow vulnerability. The process of triggering this vulnerability is quite interesting, and below we will conduct an in-depth analysis of it and introduce relevant background knowledge of the Move language. Through this explanation, we believe readers will gain a deeper understanding of the Move language.

The Move language performs code unit validation before executing bytecode, a process that consists of 4 steps. The vulnerability discussed in this article occurs during the reference_safety step.

The reference_safety module defines transfer functions used to verify the reference safety of the process subject. It mainly checks for issues such as dangling references, the safety of mutable reference access, and the safety of global storage reference access.

The verification process starts from the secure verification entry function, which calls analyze_function. In analyze_function, each basic block is verified. A basic block is a sequence of code that has no branch instructions except at the entry and exit.

The Move language identifies basic blocks by traversing the bytecode and looking for all branch instructions and loop instruction sequences. A typical example of a Move IR code basic block may contain 3 basic blocks, determined by the BrTrue, Branch, and Ret instructions.

Numen Cyber exclusively discovered another high-risk vulnerability in the move language

The Move language supports two types of references: immutable references (&) and mutable references (&mut). Immutable references are used for reading data, while mutable references are used for modifying data. This design helps maintain code safety and identify reading modules.

The main process of reference safety verification includes: scanning the bytecode instructions of basic blocks in the function and determining whether all reference operations are legal. This process uses the AbstractState structure, which contains the borrow graph and locals, to ensure the reference safety within the function.

During the verification process, the basic block code will be executed to generate the post state, then the pre state and post state will be merged to update the block state, and the post conditions of the block will be propagated to subsequent blocks. This process is similar to the Sea of Nodes concept in the V8 turbofan.

Numen Cyber exclusively discovered another critical vulnerability in the move language

The vulnerability occurs in the join_ function. When the sum of the parameter length and the local variable length exceeds 256, an integer overflow occurs because local is of u8 type. Although Move has a process to check the number of locals, the check bounds module only verifies locals and does not include the parameter length.

Numen Cyber exclusive discovery of another critical vulnerability in the move language

This integer overflow vulnerability could lead to a DoS attack. By creating a loop code block and exploiting the overflow to change the block's state, the new locals map can differ from the previous one. When the execute_block function is executed again, if the index that the instruction needs to access does not exist in the new AbstractState locals map, it will result in a DoS.

We found that the MoveLoc/CopyLoc/FreeRef opcodes in the reference safety module can achieve this goal. Taking the copy_loc function as an example, if the LocalIndex does not exist, it will lead to a panic, causing the entire node to crash.

Numen Cyber exclusive discovery of another high-risk vulnerability in the move language

To verify this vulnerability, we wrote a PoC. The code block in this PoC contains an unconditional branch instruction that jumps back to the first instruction every time the last instruction is executed, so this code block will repeatedly call the execute_block and join functions.

Numen Cyber exclusive discovery of another high-risk vulnerability in the move language

By setting appropriate parameters, we can make the length of the new locals map become 8. When the execute_block function is executed for the second time, a panic will occur due to insufficient locals length.

Numen Cyber exclusively discovered another high-risk vulnerability in the move language

This vulnerability reminds us that even languages like Move, which emphasize security, can have flaws. We recommend that Move language designers add more checking code at runtime to prevent unexpected situations. Currently, security checks in the Move language mainly occur during the verify phase, but this may not be sufficient. Once verification is bypassed, if there is not enough security reinforcement in the runtime phase, it could lead to more severe issues.

As a leader in Move language security research, we will continue to delve into the security issues of Move and share more findings in the future.

View Original
This page may contain third-party content, which is provided for information purposes only (not representations/warranties) and should not be considered as an endorsement of its views by Gate, nor as financial or professional advice. See Disclaimer for details.
  • Reward
  • 9
  • Share
Comment
0/400
ChainMelonWatchervip
· 07-16 05:21
There is a bug again, the security of move is not very good!
View OriginalReply0
AirdropHunterXiaovip
· 07-14 01:33
Digging holes, there are good jobs again.
View OriginalReply0
ChainSherlockGirlvip
· 07-13 17:05
Ha! Another on-chain security vulnerability drama, this time it’s the integer overflow show performed by Move~ According to my personal analysis, it’s likely that some Large Investors are going to take the opportunity to shorting again.
View OriginalReply0
SerumSquirtervip
· 07-13 11:48
Another security issue, it's over.
View OriginalReply0
rugged_againvip
· 07-13 11:46
Out again, slipped away.
View OriginalReply0
LiquidatedDreamsvip
· 07-13 11:42
Who is still playing move?
View OriginalReply0
DarkPoolWatchervip
· 07-13 11:31
Aptos is indeed unreliable, a bunch of vulnerabilities.
View OriginalReply0
MondayYoloFridayCryvip
· 07-13 11:28
Did you move again, Heihei? Tsk tsk tsk
View OriginalReply0
PretendingSeriousvip
· 07-13 11:22
This hole is too obvious, the development foundation is not solid.
View OriginalReply0
View More
Trade Crypto Anywhere Anytime
qrCode
Scan to download Gate app
Community
English
  • 简体中文
  • English
  • Tiếng Việt
  • 繁體中文
  • Español
  • Русский
  • Français (Afrique)
  • Português (Portugal)
  • Bahasa Indonesia
  • 日本語
  • بالعربية
  • Українська
  • Português (Brasil)