The test script for MerkleAirdrop
utilizes Foundry's Foreign Function Interface (FFI) capability to execute arbitrary code at the operating system level, which poses significant security risks. This feature, if misused or exploited in malicious or vulnerable scripts, can lead to severe implications including system compromise or data leakage.
The function testPwned()
in MerkleAirdrop.t.sol
uses FFI to execute system-level commands. Specifically, it uses the touch
command to create or update a file named "youve-been-pwned" on the host machine. This demonstrates the potential for test scripts to perform unauthorized actions beyond the Ethereum Virtual Machine (EVM) environment, affecting the host system directly.
Importantly, the invocation of this function is triggered instantaneously as part of the automated processes defined in the Makefile's make command, significantly raising the potential for unintended consequences.
By enabling FFI in test environments, developers expose their systems to a range of attacks that could lead to unauthorized access or manipulation of the filesystem, execution of arbitrary and potentially harmful commands, and other unintended actions that could compromise both the integrity and confidentiality of the system.
Foundry, maual review.
Disable the FFI capability in Foundry's configuration when not strictly necessary, particularly in shared or public codebases, to prevent the execution of arbitrary system commands.
Review and audit any use of FFI in smart contract development environments to ensure that it is used securely and only where absolutely necessary.
Implement strict access controls and review processes for any scripts that require FFI capabilities to mitigate potential security risks.
To disable FFI, modify the foundry.toml
configuration file:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.