Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

FFI is enabled by default, anyone can run arbitrary commands

Summary

The SantasListTest testPwned function employs the Foreign Function Interface (FFI) to execute commands. The project configuration (foundry.toml) reveals that FFI is enabled. The interface _CheatCodes declares a function allowing arbitrary commands execution. This raises significant security concerns regarding the potential manipulation of tests and execution of malicious commands.

Vulnerability Details

  1. FFI Usage in testPwned Function:

    • The testPwned function utilizes FFI, providing a gateway for executing arbitrary commands during tests.

    • Lack of proper input validation and access controls in the FFI execution may lead to security vulnerabilities.

  2. Configuration (foundry.toml):

    • The foundry.toml configuration file indicates FFI is enabled, increasing the risk of arbitrary command execution.

  3. Interface _CheatCodes:

    • The _CheatCodes interface declares the function ffi(string[] calldata) external returns (bytes memory);.

    • The function signature allows for arbitrary command execution if FFI is enabled.

Impact

The security implications include potential:

  • Manipulation of test results.

  • Execution of arbitrary commands, leading to data loss or service disruption.

  • Unauthorized access to sensitive information in testing environments.

Tools Used

  • Manual Review

Recommendations

  1. Disable FFI by Default:

    • Change the default configuration in foundry.toml to disable FFI, reducing the risk of arbitrary command execution.

  2. Access Controls:

    • Implement robust access controls to restrict who can enable FFI and execute arbitrary commands.

  3. Secure Defaults:

    • Enable FFI only when absolutely necessary and as a last resort. Avoid enabling it by default to prevent misuse.

  4. Monitoring:

    • Implement thorough monitoring mechanisms to track FFI usage and command execution.

  5. Educational Guidance:

    • Provide clear documentation and educational guidance on the risks associated with enabling FFI and executing arbitrary commands.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

test_pwned FFI vulnerability

The FFI variable within Foundry.TOML was set to TRUE. This variable gives foundry shell access and allows it to run commands on your terminal. The possibility of exploitation through this means are endless! This repo exploited this flag through test_pwned Keep an eye out before running tests!

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.