Beatland Festival

AI First Flight #4
Beginner FriendlyFoundrySolidityNFT
EXP
View results
Submission Details
Impact: high
Likelihood: high
Invalid

Enabled FFI and Malicious Shell Command Execution in Test Suite

Description

The project configuration enables Foundry Foreign Function Interface (ffi = true) globally, and includes test code that executes shell commands via vm.ffi().

In test/FestivalPass.t.sol, the test test_PartialUserFlow() defines a multi-step bash script interacting directly with the developer's /dev/tty terminal and executes it using vm.ffi(inputs).

// File: test/FestivalPass.t.sol
408: // --- Improved FFI "Hacking" Animation ---
409: function test_PartialUserFlow() public {
...
421: string[] memory inputs = new string[](3);
422: inputs[0] = "bash";
423: inputs[1] = "-c";
424: @> inputs[2] = string.concat(
425: "echo -e '\\033[36m[*] Scanning local environment...\\033[0m' > /dev/tty; sleep 0.4; ",
...
447: @> vm.ffi(inputs);

Risk

Likelihood:

  • Always occurs whenever any developer, auditor, or automated CI/CD pipeline runs forge test.

Impact:

  • Host compromise / supply chain risk: Arbitrary shell command execution on local machines and CI environments running tests.

Proof of Concept

Run forge test --match-test test_PartialUserFlow:
Foundry executes the subshell process and terminal interaction directly on the host machine.

Recommended Mitigation

  1. Remove ffi = true from foundry.toml unless strictly necessary and sandboxed.

  2. Remove any arbitrary shell invocations (vm.ffi) from tests.

// foundry.toml
-[profile.default]
-ffi = true
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 1 hour ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!