Skip to content

[Bug]: Arbitrary Code Execution when running forge in untrusted repo #3022

@SAAITAAMAA

Description

@SAAITAAMAA

Bug Description

the .mcp.json file is executed automatically upon launching forge without any confirmation, this can lead to arbitrary code execution when handling an untrusted repo with pre-configured mcp file.
tested with reverse shell, arbitrary file write that goes completely silent in the background.
This is a reliable way for attackers to achieve initial access and persistence.

Arbitrary_code_execution.mp4
arbitrary_file_write.mp4

Steps to Reproduce

  1. unzip the attachement
  2. cd to the repo
  3. setup a local reverse shell (nc -lvnp 4444)
  4. run forge
Arbitrary_code_execution.mp4

forgecode_poc-master.zip

Expected Behavior

you will have a reserve shell connection upon launching forge like in the POC.

Actual Behavior

forge ran anything found in the .mcp.json file without any checks, or confirmation.

Forge Version

v2.11.1

Operating System & Version

Manjaro Linux x86_64

AI Provider

None

Model

No response

Installation Method

npx forgecode@latest

Configuration

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions