Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOB-FUEL-40: MCPI instruction is not charging gas depending on the input value #572

Closed
xgreenx opened this issue Aug 29, 2023 · 1 comment
Labels
audit-report Issue from the audit report

Comments

@xgreenx
Copy link
Collaborator

xgreenx commented Aug 29, 2023

Description

The instruction MCPI (copy memory) currently does not charge depending on the amount of memory which is being copied.

Figure 41.1: MCPI is missing a dependent gas charge. (fuel-vm/fuel-vm/src/interpreter/executors/instruction.rs#654–666)

Instruction::MCP(mcp) => {
    let (a, b, c) = mcp.unpack();
    let len = r!(c);
    self.dependent_gas_charge(self.gas_costs.mcp, len)?;
    self.memcopy(r!(a), r!(b), len)?;
}
Instruction::MCPI(mcpi) => {
    self.gas_charge(self.gas_costs.mcpi)?;
    let (a, b, imm) = mcpi.unpack();
    let len = imm.into();
    self.memcopy(r!(a), r!(b), len)?;
}

Exploit Scenario

An attacker deploys a contract which heavily uses the above MCPI instruction. With very little gas consumption the attack can put a lot of stress on the network. Depending on how much gas the attacker invests the whole network could be blocked.

Recommendations

Short term, introduce a dependent cost for the MCPI instruction
Long term, reevaluate the execution time of programs using a corpus obtained through fuzzing.

@xgreenx xgreenx added the audit-report Issue from the audit report label Aug 29, 2023
@xgreenx
Copy link
Collaborator Author

xgreenx commented Aug 29, 2023

Fixed with #537, requires follow-up PR on the fuel-core side FuelLabs/fuel-core#1325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit-report Issue from the audit report
Projects
None yet
Development

No branches or pull requests

1 participant