Skip to content

forge test crashes on macOS when SCDynamicStore returns NULL in sandboxed environment #12733

@uri-99

Description

@uri-99

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

1.5.0-stable

What version of Foundryup are you on?

1.4.0

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

Running forge test in a sandboxed environment causes a panic when Foundry attempts to read macOS system proxy configuration.

Error message:

The application panicked (crashed).
Message:  Attempted to create a NULL object.
Location: /Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/system-configuration-0.6.1/src/dynamic_store.rs:154

This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry

Relevant backtrace:

 8: system_configuration::dynamic_store::SCDynamicStoreBuilder<T>::build
 9: hyper_util::client::proxy::matcher::mac::with_system
10: hyper_util::client::proxy::matcher::Builder::from_system
11: hyper_util::client::proxy::matcher::Matcher::from_system
12: reqwest::async_impl::client::ClientBuilder::build
13: foundry_common::provider::runtime_transport::RuntimeTransport::reqwest_client
14: foundry_common::selectors::OpenChainClient::new
15: foundry_evm_traces::identifier::signatures::SignaturesIdentifier::new_with
16: foundry_evm_traces::identifier::signatures::SignaturesIdentifier::from_config
17: forge::cmd::test::TestArgs::run_tests_inner
18: forge::cmd::test::TestArgs::run_tests
19: forge::cmd::test::TestArgs::compile_and_run

Root cause:

When creating the OpenChainClient for signature lookups, Foundry builds a reqwest HTTP client. On macOS, this triggers reading system proxy settings via SCDynamicStore. In sandboxed environments (e.g., Cursor IDE sandbox, App Sandbox, or restricted shells), the SCDynamicStore API returns NULL, which causes the system-configuration crate to panic.

Reproduction steps:

  1. Run forge test in a sandboxed macOS environment (e.g., within an IDE that sandboxes terminal commands)
  2. Observe the crash

Workarounds:

  • Use --offline flag to disable signature lookups
  • Run outside the sandbox

Note: Lower verbosity does not help - the crash occurs during initialization regardless of verbosity level.

Suggested fix

The code should gracefully handle the case where SCDynamicStore returns NULL instead of panicking. This could be done by:

  1. Catching the NULL case in foundry_common before building the reqwest client
  2. Falling back to no proxy when system proxy detection fails
  3. Or using reqwest's no_proxy() option when in environments where system proxy detection might fail

This would make Foundry more robust when running in sandboxed/restricted environments on macOS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-bugType: bugT-needs-triageType: this issue needs to be labelled

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions