← MCP server and skill grades

ghidra-mcp

bethington/ghidra-mcp

F
Type
MCP server
Scanned
Nov 13, 2026
Version
5f6c416ffe97
Files read
732

Ghidra MCP connects AI assistants to the Ghidra reverse-engineering tool so they can analyze, decompile, edit, and debug compiled programs. The biggest risk is that a malicious website you visit or a tricked AI assistant can use its local server to launch arbitrary programs on your computer through Ghidra's debugger or delete your project files.

What it can reach

Files
Reads binaries, archives, scripts, and settings from disk, writes exported programs and decompiled C code to local folders, and creates, edits, or deletes Ghidra projects.
Network
Runs a local server on a network port and local socket, optionally serves MCP over HTTP, and can connect to remote Ghidra Servers, an external debugger server, or a documentation archive URL.
Shell commands
Launches local programs and Python launchers through Ghidra's debugger by default, and runs arbitrary Java or Python scripts inside Ghidra when script execution is enabled.
Secrets
Reads authentication tokens and shared Ghidra Server passwords from environment variables, .env files, and saved .ghidra-cred files.
System
Attaches to running local processes to inspect memory and registers, controls Ghidra windows and confirmation dialogs, and can close the Ghidra application.

Findings

1 critical1 high2 medium12 low
  1. CriticalCross-origin GET requests bypass CSRF protection and execute POST endpoints

    src/main/java/com/xebyte/core/McpHttpServer.java:83

    By default in GUI mode, GhidraMCP listens on http://127.0.0.1:8089 without an authentication token and relies on SecurityConfig.rejectCrossOriginRequest to block browser attacks. However, rejectCrossOriginRequest only rejects a request when an Origin header is present and non-loopback, and browsers omit the Origin header on cross-origin GET requests such as top-level form submissions, popups, and image or script loads while sending Host: 127.0.0.1:8089. Because McpHttpServer.endpoints never verifies that exchange.getRequestMethod() matches the tool's declared HTTP method (POST), and AnnotationScanner falls back to reading URL query parameters when the request body is empty, any website the user visits can invoke POST tools via GET requests with query parameters—including launching executables via /debugger/launch, deleting project files via /delete_file, discarding unsaved work via /close_program, or shutting down Ghidra via /exit_ghidra.

    Fix: Verify that exchange.getRequestMethod() matches ep.method() in McpHttpServer.endpoints (returning 405 when they differ), convert mutating GET routes (/save_program, /save_all_programs, /switch_program) to POST, and reject requests carrying Sec-Fetch-Site: cross-site or same-site in SecurityConfig.rejectCrossOriginRequest.

  2. HighGUI debugger launch endpoint executes arbitrary host binaries and DLLs by default without file-root or opt-in checks

    src/main/java/com/xebyte/core/DebuggerService.java:494

    While arbitrary script execution (/run_ghidra_script and /run_script_inline) is disabled by default behind GHIDRA_MCP_ALLOW_SCRIPTS, the GUI plugin registers /debugger/launch on by default and even auto-starts Ghidra's Debugger window if it is closed. If prompt injection in an analyzed binary or external text tricks the AI agent into calling load_tool_group("debugger") and debugger_launch, the endpoint runs any executable_path with arbitrary args, allows python_executable (OPT_PYTHON_EXE) to execute an arbitrary binary as the launcher interpreter, and allows windbg_dir (WINDBG_DIR) to load dbgeng.dll from any local or UNC folder, without checking GHIDRA_MCP_FILE_ROOT on any of those paths.

    Fix: Gate /debugger/launch behind an explicit opt-in environment variable similar to GHIDRA_MCP_ALLOW_SCRIPTS, validate executable_path and cwd against SecurityConfig.resolveWithinFileRoot, remove caller-controlled python_executable and windbg_dir overrides from the HTTP API, and mark the tool as ToolAccess.DESTRUCTIVE.

  3. MediumUnix socket discovery scans /tmp without ownership checks, allowing local backend spoofing and token theft

    python/bridge_mcp_ghidra/discovery.py:84

    On startup and during background retries, discover_instances() scans every candidate directory including /tmp/ghidra-mcp-<user> (and <drive>:\tmp\ghidra-mcp-<user> on Windows) even when XDG_RUNTIME_DIR is active. It never verifies that the directory or .sock file is owned by the current UID, and is_pid_alive() treats processes owned by other users (such as PID 1) as alive. On a multi-user machine, another local user can pre-create /tmp/ghidra-mcp-<victim>/ghidra-1.sock to capture the victim's GHIDRA_MCP_AUTH_TOKEN header and serve malicious MCP tool descriptions or fake decompilation output into the victim's AI coding agent.

    Fix: Verify that candidate socket directories and socket files are not symlinks, are owned by os.getuid() on POSIX, and have permissions no broader than 0700 before connecting or sending GHIDRA_MCP_AUTH_TOKEN.

  4. MediumDecompilation tree creation ignores GHIDRA_MCP_FILE_ROOT and writes files to arbitrary empty directories

    src/main/java/com/xebyte/core/DecompTreeService.java:1071

    The /decompile_tree_create endpoint accepts an explicit root directory and writes tree.json, STATUS.md, AGENTS.md, and decompiled .c files (which include strings and comments from the binary) into that directory if it is new or empty. Unlike /open_project, DecompTreeService never validates the requested root against SecurityConfig.getInstance().resolveWithinFileRoot(), allowing a prompt-injected agent to create directories and write files outside a configured GHIDRA_MCP_FILE_ROOT.

    Fix: When GHIDRA_MCP_FILE_ROOT is configured, require any explicit root passed to /decompile_tree_create to resolve inside SecurityConfig.getInstance().resolveWithinFileRoot(), or restrict tree roots to the dedicated temp directory.

  5. LowBundled Ghidra scripts invoke Claude CLI with --dangerously-skip-permissions on untrusted binary names and code

    ghidra_scripts/VerifyThiscallConventionsClaude.java:193

    Eight scripts in ghidra_scripts/ (VerifyThiscallConventionsClaude.java, Analyze_VerifyThiscallConventions.java, DocumentFunctionWithClaude.java, Document_FunctionWithClaude.java, BatchDocumentFunctions.java, BatchDocumentFunctionsInteractive.java, Document_BatchFunctions.java, and Document_BatchFunctionsInteractive.java) spawn the claude CLI with --dangerously-skip-permissions and no --allowedTools restriction, while embedding function names from the open binary directly into the prompt. If an analyst runs one of these scripts on a malicious binary containing prompt injection in a function name, symbol, or string, the spawned Claude session can execute arbitrary shell commands without confirmation.

    Fix: Remove --dangerously-skip-permissions from all Ghidra scripts, or pass strict tool restrictions (such as --tools "" and --allowedTools restricted to non-destructive Ghidra MCP tools) so the spawned Claude process cannot run shell commands or edit host files.

  6. LowImportMSDLPDB.java enables searching untrusted PE-embedded PDB locations

    ghidra_scripts/ImportMSDLPDB.java:87

    Although documented as downloading symbols from Microsoft's symbol server, ImportMSDLPDB.java sets the Ghidra analyzer option 'PDB Universal.Search untrusted locations' to true on the program before running analysis. An untrusted PE file can embed an attacker-controlled UNC path (such as \\attacker.example\share\file.pdb) in its CodeView debug record, causing Windows to make outbound SMB connections that leak NetNTLMv2 credentials or load a malicious PDB.

    Fix: Do not enable 'PDB Universal.Search untrusted locations'; keep untrusted path searching false so Ghidra only queries trusted symbol servers configured by the user.

  7. LowHTTP bridge allows unauthenticated non-loopback binds and relays GHIDRA_MCP_AUTH_TOKEN on loopback without inbound auth

    python/bridge_mcp_ghidra/cli.py:475

    Unlike the Java server (which refuses to start on a non-loopback address without an auth token), the Python bridge allows binding streamable-http or sse to 0.0.0.0 with no token when GHIDRA_MCP_INBOUND_TOKEN and GHIDRA_MCP_AUTH_TOKEN are unset, logging only a warning while exposing all Ghidra tools to the network. Conversely, when GHIDRA_MCP_AUTH_TOKEN is set and the bridge binds 127.0.0.1 without GHIDRA_MCP_INBOUND_TOKEN, _BearerAuthMiddleware is skipped, letting any local user or localhost web origin drive the token-protected Ghidra backend through the bridge.

    Fix: Refuse non-loopback HTTP binds unless GHIDRA_MCP_INBOUND_TOKEN or GHIDRA_MCP_AUTH_TOKEN is configured (matching the Java server's fail-closed policy), and require inbound bearer auth whenever AUTH_TOKEN is set regardless of bind_host.

  8. LowFacade mode dispatches external debugger proxy tools even when disabled by default or GHIDRA_DEBUGGER_TOOLS=0

    python/bridge_mcp_ghidra/facade.py:289

    The 22 external WinDbg debugger_* proxy tools are disabled by default unless GHIDRA_DEBUGGER_URL or GHIDRA_DEBUGGER_TOOLS=1 is set, and GHIDRA_DEBUGGER_TOOLS=0 explicitly disables them. However, in --expose facade or hybrid mode, _call_static_sync() looks up any debugger_* function directly on the debugger module without checking _DEBUGGER_ACTIVE, allowing ghidra_call to invoke disabled debugger proxies and shadowing Ghidra's built-in TraceRmi debugger endpoints of the same name.

    Fix: Check _dbg._DEBUGGER_ACTIVE in _call_static_sync() before dispatching debugger_* calls so disabled proxy tools are not callable and fall through to the Ghidra schema.

  9. LowUnbounded P-code emulation in /emulate_hash_batch can permanently hang Ghidra worker threads

    src/main/java/com/xebyte/core/EmulationService.java:442

    While /emulate_function uses a bounded step loop because EmulatorHelper.run() hangs forever on infinite loops or when the x86-32 stack return sentinel is never hit, /emulate_hash_batch still calls emu.run() with an uncancelled ConsoleTaskMonitor and only initializes 32-bit ESP/EBP. Calling /emulate_hash_batch on a non-returning loop or a 64-bit/ARM function can spin indefinitely and exhaust Ghidra's HTTP thread pool.

    Fix: Replace emu.run() in emulateHashBatch with a bounded emu.step() loop capped by a per-candidate step limit, and initialize architecture-appropriate return addresses (such as RSP or LR).

  10. LowSource deploy command copies .env secrets into the Ghidra installation directory

    tools/setup/ghidra.py:2788

    When a developer runs 'python -m tools.setup deploy', deploy_to_ghidra() copies any .env file from the repository root directly into the target Ghidra installation directory without restricting file permissions or warning in the README. If .env holds GHIDRA_SERVER_PASSWORD, GHIDRA_MCP_AUTH_TOKEN, or provider API keys and Ghidra is installed in a shared path such as /opt or C:\ghidra_*, other local users may be able to read those secrets.

    Fix: Stop copying .env into the shared Ghidra installation directory (keep secrets in the user's home or profile directory with 0600 permissions), or require an explicit flag and set restrictive file permissions.

  11. LowBare-filename lookup bypasses GHIDRA_MCP_PROJECT_FOLDER scope confinement

    src/main/java/com/xebyte/core/ProjectProgramProvider.java:301

    When the operator sets GHIDRA_MCP_PROJECT_FOLDER to confine the server to a single subfolder of a Ghidra project, ProjectProgramProvider.findDomainFile only enforces that scope when the caller passes a path starting with '/'. When given a bare filename without a leading slash, findDomainFile walks the entire project from getRootFolder() via collectByName without checking SecurityConfig.isPathInProjectScope. Calling /export_program with a bare filename exports an out-of-scope binary to disk, and calling /open_program with a bare filename opens the out-of-scope binary as the active program, allowing subsequent tool calls that omit the program parameter to read and modify it.

    Fix: Check SecurityConfig.getInstance().isPathInProjectScope(f.getPathname()) inside ProjectProgramProvider.collectByName and collectProgramPaths, and enforce inProjectScope in openDomainFile and getCurrentProgram.

  12. LowAuto-authenticator sends Ghidra Server password to any server without host verification

    src/main/java/com/xebyte/core/GhidraMCPAuthenticator.java:94

    When GHIDRA_SERVER_PASSWORD or a .ghidra-cred file is configured (or credentials are set via /server/authenticate), GhidraMCPAuthenticator registers as the process-wide Ghidra ClientAuthenticator. Its processPasswordCallbacks method supplies the stored username and password without checking the serverName parameter against GHIDRA_SERVER_HOST. If an AI agent is tricked into opening a shared project pointing to an external server (for example via GUI /open_project with a ghidra:// URL, or /restore_project followed by /open_project on a crafted project archive), Ghidra automatically transmits the user's password to that server.

    Fix: Store the expected GHIDRA_SERVER_HOST in GhidraMCPAuthenticator and refuse to populate PasswordCallback in processPasswordCallbacks when serverName does not match the configured host.

  13. LowHeadless project deletion and creation can step outside GHIDRA_MCP_FILE_ROOT

    src/main/java/com/xebyte/headless/HeadlessProgramProvider.java:492

    In headless mode, /delete_project checks that projectPath resolves at or under GHIDRA_MCP_FILE_ROOT, which succeeds when projectPath equals GHIDRA_MCP_FILE_ROOT itself. Because that path does not end in .gpr, HeadlessProgramProvider.deleteProject sets projectDir to projectFile.getParentFile()—the parent directory outside GHIDRA_MCP_FILE_ROOT—and deletes <root>.gpr and <root>.rep there. Similarly, HeadlessManagementService.createProject checks parentDir against GHIDRA_MCP_FILE_ROOT but does not validate the project name parameter with SafePaths.validateFilename or SafePaths.isWithin.

    Fix: Require resolved paths in /delete_project (including the derived .gpr file and .rep directory) and /create_project (validating name with SafePaths.validateFilename and SafePaths.isWithin) to stay strictly inside GHIDRA_MCP_FILE_ROOT.

  14. LowMulti-instance Docker Nginx config exposes wildcard CORS and omits auth token

    docker/nginx.conf:114

    The optional multi-instance Docker setup (docker-compose.multi.yml with docker/nginx.conf) publishes port 8089 on all interfaces, omits the required GHIDRA_MCP_AUTH_TOKEN environment variable on the ghidra-mcp service, and configures Nginx to add Access-Control-Allow-Origin: * to every HTTP response. Wildcard CORS headers allow arbitrary websites visited in a browser to read responses from unauthenticated routes (and any backend run without a token) across origins.

    Fix: Remove the wildcard Access-Control-Allow-Origin headers from docker/nginx.conf and require GHIDRA_MCP_AUTH_TOKEN in docker/docker-compose.multi.yml just as in docker/docker-compose.yml.

  15. LowContainer runtime user owns application binaries in /app

    docker/Dockerfile:158

    The Dockerfile switches to the unprivileged ghidra user to contain parser or file-write bugs when analyzing untrusted binaries, but it also grants ghidra ownership of /app, where GhidraMCP.jar and entrypoint.sh live. If a file-write flaw in a binary parser or unrestricted file operation writes into /app, the unprivileged process could overwrite its own JAR or entrypoint script and execute modified code when the container restarts.

    Fix: Keep /app, /app/GhidraMCP.jar, and /app/entrypoint.sh owned by root:root with read-only permissions (0755 for directories and entrypoint.sh, 0644 for GhidraMCP.jar), and chown only /data, /projects, and /home/ghidra to ghidra:ghidra.

  16. LowPowerShell test runner auto-installs unpinned module with publisher check skipped

    tests/pester/Run-Tests.ps1:24

    When Pester 5.5.0 or newer is not installed, this developer test runner downloads the latest version from the PowerShell Gallery using an unpinned -MinimumVersion along with -SkipPublisherCheck, -Force, and -AllowClobber, and immediately imports it. Skipping publisher signature checks on an unpinned download weakens supply-chain safety for contributors running the test suite, though normal users of the installed MCP server never run this script.

    Fix: Pin a specific version using -RequiredVersion instead of -MinimumVersion, and either require Pester to be pre-installed or verify the package hash/publisher certificate rather than bypassing verification with -SkipPublisherCheck.