Skip to content

fix(security): pin ACP npx launchers to reviewed versions (closes #3357) - #3399

Merged
simonrosenberg merged 1 commit into
OpenHands:mainfrom
Sanjays2402:security/pin-acp-npx-versions
Jun 8, 2026
Merged

simonrosenberg merged 1 commit into
OpenHands:mainfrom
Sanjays2402:security/pin-acp-npx-versions

Conversation

@Sanjays2402

@Sanjays2402 Sanjays2402 commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:
pin ACP npx launchers to reviewed versions

  • A human has tested these changes.

AGENT:

Rebases and salvages #3399 onto current main, reconciled with the ACP
binary-rewrite design merged in #3490. Original work by @Sanjays2402
(co-authored on the commit); a maintainer pushed the reconciled version to
this same branch.

Changes vs. the original #3399:

  • Pin versions now match main's Dockerfile exactly (the single source of
    truth): codex-acp@0.15.0 (was a stale 0.11.1) and gemini-cli@0.38.0
    (was 0.39.1). claude-agent-acp@0.30.0 unchanged.
  • Dropped the out-of-scope Dockerfile gemini-cli bump — the SDK pin tracks
    the Dockerfile, it does not change it.
  • Reconciled with feat(acp): launch pinned pre-installed CLI binary instead of npx #3490: a version-pinned default would otherwise break the
    image-binary rewrite for an explicit unpinned npx command (canvas's
    fallback path), silently running npm-latest in the image. Fixed by matching
    the provider package by name (ignoring any @version) in
    _prefer_pinned_binary, so the pinned binary stands in regardless of the
    requested version. The native (no-binary) path keeps the pin.

Verification (clean worktree off main; uv.lock churn reverted):

ruff check / ruff format --check (4 changed files) ......... clean
pytest tests/sdk/test_settings.py tests/sdk/settings/ \
       tests/sdk/agent/test_acp_agent.py ................... 580 passed
pytest tests/agent_server/test_conversation_router_acp.py \
       tests/agent_server/test_openapi_discriminator.py \
       tests/cross/test_check_agent_server_rest_api_breakage.py \
       tests/cross/test_check_sdk_api_breakage.py ........... passed

Runtime check of ACPAgentSettings.resolve_acp_command():

registry default_command (pinned):
  claude-code: ['npx','-y','@agentclientprotocol/claude-agent-acp@0.30.0']
  codex:       ['npx','-y','@zed-industries/codex-acp@0.15.0']
  gemini-cli:  ['npx','-y','@google/gemini-cli@0.38.0','--acp']

native fallback (no binary on PATH)   -> pinned npx command (as above)
image (binaries on PATH), default     -> ['claude-agent-acp'] / ['codex-acp'] / ['gemini','--acp']
image, explicit npx bare/pinned/drifted:
  npx @zed-industries/codex-acp        -> ['codex-acp']
  npx @zed-industries/codex-acp@0.15.0 -> ['codex-acp']
  npx @zed-industries/codex-acp@0.11.1 -> ['codex-acp']

The REST-API breakage cross-check passes, so the OpenAPI example change does
not alter the published schema.


Why

Closes #3357.

The three built-in ACP providers in openhands.sdk.settings.acp_providers
launched with floating npx -y <pkg> commands. On the native launch path
(a host with no pre-installed ACP binary), the package version is resolved from
npm's latest at agent-launch time — after commit review and after the
[tool.uv] exclude-newer guardrail on the Python lock. Each provider also
defaults to a permission-disabling session mode (bypassPermissions,
full-access, yolo), so a poisoned or unexpectedly broken latest publish
would be fetched and executed under a high-trust mode on the next launch.

In the agent-server image these packages are pre-installed as PATH binaries and
#3490 already rewrites the npx command to the pinned binary, so the gap is
only the native fallback. Hardening, not a report of an active exploit.

Summary

  • Pin default_command for claude-code, codex, and gemini-cli in
    acp_providers.py via module-level constants matching the agent-server
    Dockerfile (the single source of truth):
    @agentclientprotocol/claude-agent-acp@0.30.0,
    @zed-industries/codex-acp@0.15.0, @google/gemini-cli@0.38.0.
  • Reconcile with feat(acp): launch pinned pre-installed CLI binary instead of npx #3490: make _prefer_pinned_binary match the provider package
    by name (ignoring any @version) so the image-binary rewrite still fires for
    the pinned default and for any npx command a client sends (bare, pinned, or
    drifted); only the native fallback carries the pin. Adds
    ACPAgentSettings._npm_package_name.
  • Fix the OpenAPI example in conversation_router_acp.py — previously
    npx -y claude-agent-acp (unscoped name, 404 on npm today, registerable by
    anyone → dependency-confusion footgun). Now the scoped, pinned default.
  • Update the affected tests in tests/sdk/test_settings.py (default-command
    and native-fallback forms) and add a test asserting the version-agnostic
    rewrite to the pinned binary.

Issue Number

Closes #3357

How to Test

uv run pytest tests/sdk/test_settings.py tests/sdk/settings/test_acp_providers.py

Or by inspection:

from openhands.sdk.settings.acp_providers import ACP_PROVIDERS
for k, v in ACP_PROVIDERS.items():
    print(k, list(v.default_command))
# claude-code ['npx', '-y', '@agentclientprotocol/claude-agent-acp@0.30.0']
# codex       ['npx', '-y', '@zed-industries/codex-acp@0.15.0']
# gemini-cli  ['npx', '-y', '@google/gemini-cli@0.38.0', '--acp']

The SDK pins and the Dockerfile npm install -g line are now identical, so
build-time and native runtime versions cannot diverge.

Video/Screenshots

N/A — no UI change.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • default_command is a tuple of str; only its contents changed. Callers
    building their own command via ACPAgent(acp_command=[...]) are unaffected.
  • Bumping a version requires editing both the constants block in
    acp_providers.py and the Dockerfile npm install -g line; a comment on the
    constants points at the Dockerfile to make that contract explicit.
  • Follow-up (non-blocking, downstream): the @openhands/typescript-client ACP
    registry mirrors these defaults. It can be synced to the pinned forms for
    tidiness, but the name-based rewrite means the image launches the pinned
    binary even if the mirror temporarily lags.

@all-hands-bot
all-hands-bot requested a review from VascoSch92 May 29, 2026 14:00
@all-hands-bot

Copy link
Copy Markdown
Collaborator

[Automatic Post]: I have assigned @VascoSch92 as a reviewer based on git blame information. Thanks in advance for the help!

This comment was created by an AI agent (OpenHands) on behalf of the user.

# - ``GEMINI_CLI_VERSION`` — bumped to a patched release (>= 0.39.1)
# ---------------------------------------------------------------------------

CLAUDE_AGENT_ACP_VERSION = "0.30.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Final from typing

@VascoSch92
VascoSch92 requested a review from simonrosenberg May 29, 2026 14:03
@VascoSch92

Copy link
Copy Markdown
Member

I believe @simonrosenberg knows better than me ACP...

@simonrosenberg simonrosenberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sanjays2402 one minor nit: the updated assertion in tests/sdk/test_settings.py hardcodes the version string rather than importing the constant you defined:

# current
assert agent.acp_command == [
    "npx",
    "-y",
    "@agentclientprotocol/claude-agent-acp@0.30.0",
]

If CLAUDE_AGENT_ACP_VERSION is bumped in a future commit, this test will silently diverge and fail without making it obvious why. Better to import and use the constant:

from openhands.sdk.settings.acp_providers import CLAUDE_AGENT_ACP_VERSION

assert agent.acp_command == [
    "npx",
    "-y",
    f"@agentclientprotocol/claude-agent-acp@{CLAUDE_AGENT_ACP_VERSION}",
]

The two tests in tests/sdk/settings/test_acp_providers.py use in assertions so they're already resilient — just this one needs the fix. Everything else looks great, thanks for the thorough writeup!

@simonrosenberg simonrosenberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sanjays2402 second concern: the gemini-cli version bump is out of scope for this PR and should be removed.

The job of a pinning PR is mechanical — read what the Dockerfile already installs, write those exact versions into acp_providers.py. For claude-agent-acp (0.30.0) and codex-acp (0.11.1) that's what happens. For gemini-cli the PR also bumps the Dockerfile from 0.38.0 → 0.39.1, which is a separate change bundled into what reads as a config-only hardening fix.

Problems with bundling the bump here:

  • 0.38.0 is what production images have been running; 0.39.1 has not been validated in this repo.
  • Someone reviewing "pin floating npx versions" is not necessarily signing off on "also upgrade gemini-cli."
  • It defeats the stated goal of the PR: after merge the Dockerfile and acp_providers.py agree, but on a version that wasn't previously reviewed for this repo.

Please revert the gemini-cli pin to 0.38.0 in both acp_providers.py and the Dockerfile, and open the upgrade as a separate PR where it can be justified and tested on its own merits.

@all-hands-bot

Copy link
Copy Markdown
Collaborator

[Automatic Post]: It has been a while since there was any activity on this PR. @Sanjays2402, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up.

This comment was created by an AI agent (OpenHands) on behalf of the user.

…nHands#3357)

The three built-in ACP providers launched with floating `npx -y <pkg>`
commands, so on the native (no pre-installed binary) path the package
version was resolved from npm `latest` at agent-launch time — after commit
review and the `[tool.uv] exclude-newer` lock guardrail — and each provider
runs under a permission-disabling default session mode.

- Pin `default_command` for `claude-code`, `codex`, and `gemini-cli` via
  module-level constants matching the agent-server Dockerfile (the single
  source of truth): claude-agent-acp@0.30.0, codex-acp@0.15.0,
  gemini-cli@0.38.0.
- Make `_prefer_pinned_binary` match the provider package by name (ignoring
  any `@version`) so the image binary rewrite from OpenHands#3490 still fires for the
  pinned default and for any npx command a client sends (bare or drifted),
  while only the native fallback carries the pin.
- Fix the OpenAPI example in conversation_router_acp.py to use the scoped,
  pinned `@agentclientprotocol/claude-agent-acp@0.30.0` (the unscoped
  `claude-agent-acp` 404s on npm and is a dependency-confusion footgun).

Supersedes OpenHands#3399.

Co-authored-by: Sanjay Santhanam <51058514+Sanjays2402@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@simonrosenberg
simonrosenberg force-pushed the security/pin-acp-npx-versions branch from 1240804 to 1fdc167 Compare June 8, 2026 12:47

all-hands-bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: Pin ACP npx launchers to reviewed versions

Taste Rating

🟢 Good taste - Clean, well-designed security fix with minimal complexity.

Summary

This PR implements a supply chain security fix by pinning npm package versions for ACP launchers. The approach is pragmatic and well-engineered:

  1. Version pinning prevents fetching untrusted npm latest versions at runtime
  2. Version-agnostic matching allows the binary rewrite to work regardless of what version a client sends
  3. Single source of truth comment documents the sync requirement with the Dockerfile

Analysis

[CRITICAL ISSUES]
None — this is a solid security fix.

[IMPROVEMENT OPPORTUNITIES]
None — the implementation is appropriately minimal.

[EXISTING COMMENT]
There's an open comment from @VascoSch92 about using Final from typing for the version constants (line 394). This is a reasonable suggestion for immutability guarantees, but since these are module-level constants in a frozen dataclass environment, it's not blocking.

[TESTING]
The tests are comprehensive:

  • Updated test expectations for pinned versions
  • New test test_acp_resolve_command_rewrites_versioned_npx_to_pinned_binary covers the version-agnostic matching for multiple version formats (bare, pinned, drifted)

Risk Assessment

  • [Overall PR] ⚠️ Risk Assessment: 🟢 LOW

This PR reduces supply chain attack surface by pinning npm package versions. The change is backward-compatible (binary rewrite still works as before) and adds a defense-in-depth layer. No new attack vectors are introduced.

VERDICT:
✅ Worth merging: Clean security fix with appropriate test coverage.

KEY INSIGHT:
The version-agnostic matching in _prefer_pinned_binary is the elegant touch — it allows the binary rewrite to work even when clients send unpinned or differently-pinned package names, making the fix robust without adding complexity.


This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation

@simonrosenberg
simonrosenberg merged commit 567eb21 into OpenHands:main Jun 8, 2026
37 of 43 checks passed
pengzhang-create pushed a commit to Pyromind-Dynamics/software-agent-sdk that referenced this pull request Aug 13, 2026
…nHands#3357) (OpenHands#3399)

Co-authored-by: Simon Rosenberg <simon@openhands.dev>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pin ACP npx -y launch commands instead of resolving floating npm latest at runtime

4 participants