Skip to content

CSRF in @rsdoctor/sdk Allows Arbitrary Command Execution via the __open-in-editor Endpoint

High
yifancong published GHSA-x396-6x64-6m26 Jul 10, 2026

Package

packages/core/src/sdk/server/index.ts:212

Affected versions

v1.5.17

Patched versions

v1.5.18

Description

CSRF in @rsdoctor/sdk Allows Arbitrary Command Execution via the __open-in-editor Endpoint

Package

Package Affected versions Patched version
@rsdoctor/sdk <= 1.5.17 1.5.18

This issue also affects downstream users of @rsdoctor/rspack-plugin, @rsdoctor/webpack-plugin, and @rsdoctor/cli. Upgrade these packages to 1.5.18 or later.

Severity

High — CVSS 3.1: 8.8

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Weaknesses

  • CWE-352: Cross-Site Request Forgery
  • CWE-78: Improper Neutralization of Special Elements used in an OS Command

Description

Summary

The Rsdoctor SDK report server exposes the GET /__open-in-editor endpoint without authentication or CSRF protection.

The endpoint accepts attacker-controlled file and editor query parameters and passes them to the launch-editor package.

A malicious webpage visited by a developer with a running Rsdoctor report server can issue a cross-origin request that executes an attacker-controlled command with the privileges of the local Rsdoctor process.

This vulnerability affects @rsdoctor/sdk versions 1.5.17 and earlier and is fixed in version 1.5.18.

Details

The vulnerable endpoint is implemented in:

packages/sdk/src/sdk/server/index.ts

Before the fix:

  1. The endpoint accepted unauthenticated GET and HEAD requests.
  2. No CSRF token or equivalent request authentication was required.
  3. The editor parameter was passed directly to launch-editor.
  4. An attacker could supply shell command arguments such as sh -c id.

POC

The following proof of concept applies to Linux and macOS environments and uses the harmless id command to verify command execution.

  1. Start Rsdoctor with an affected version, such as @rsdoctor/rspack-plugin@1.5.17, and identify the report server port as <PORT>.

  2. Create a malicious webpage:

<!doctype html>
<html>
  <body>
    <img
      src="http://127.0.0.1:<PORT>/__open-in-editor?file=%2Fetc%2Fhosts&editor=sh%20-c%20id"
    />
  </body>
</html>
  1. Open the webpage in a browser.

  2. In the affected version, the request does not require a token. The server passes editor=sh -c id to launch-editor, causing the id command to execute with the privileges of the local Rsdoctor process.

  3. In the fixed 1.5.18 version, the same request is rejected with 403 Forbidden because it does not contain a valid socket token, and the command is not executed.

The PoC uses id only to print the current user identity. It does not modify or delete local files.

Impact

Successful exploitation may allow a remote attacker to execute arbitrary commands with the privileges of the local Rsdoctor process. This can result in source-code disclosure, modification or deletion of local files, credential theft, or further compromise of the developer machine.

Remediation

Upgrade to:

@rsdoctor/sdk >= 1.5.18

The fix from PR #1817:

  • Requires the server socket token for __open-in-editor requests.
  • Compares tokens using a timing-safe comparison.
  • Restricts allowed editor values to code, cursor, and trae.
  • Updates the client to include the socket token in requests.
  • Adds regression tests for missing tokens and unsupported editors.

No CVE has been assigned.

Severity

High

CVE ID

No known CVE

Weaknesses

No CWEs

Credits