Repository navigation
fix(security): pin ACP npx launchers to reviewed versions (closes #3357) - #3399
Conversation
|
[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" |
|
I believe @simonrosenberg knows better than me ACP... |
simonrosenberg
left a comment
There was a problem hiding this comment.
@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
left a comment
There was a problem hiding this comment.
@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.0is what production images have been running;0.39.1has 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.pyagree, 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.
|
[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>
1240804 to
1fdc167
Compare
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
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:
- Version pinning prevents fetching untrusted
npm latestversions at runtime - Version-agnostic matching allows the binary rewrite to work regardless of what version a client sends
- 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_binarycovers 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
…nHands#3357) (OpenHands#3399) Co-authored-by: Simon Rosenberg <simon@openhands.dev> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
HUMAN:
pin ACP npx launchers to reviewed versions
AGENT:
Rebases and salvages #3399 onto current
main, reconciled with the ACPbinary-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:
main's Dockerfile exactly (the single source oftruth):
codex-acp@0.15.0(was a stale0.11.1) andgemini-cli@0.38.0(was
0.39.1).claude-agent-acp@0.30.0unchanged.gemini-clibump — the SDK pin tracksthe Dockerfile, it does not change it.
image-binary rewrite for an explicit unpinned
npxcommand (canvas'sfallback 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 therequested version. The native (no-binary) path keeps the pin.
Verification (clean worktree off
main;uv.lockchurn reverted):Runtime check of
ACPAgentSettings.resolve_acp_command():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_providerslaunched 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
latestat agent-launch time — after commit review and after the[tool.uv] exclude-newerguardrail on the Python lock. Each provider alsodefaults to a permission-disabling session mode (
bypassPermissions,full-access,yolo), so a poisoned or unexpectedly brokenlatestpublishwould 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
npxcommand to the pinned binary, so the gap isonly the native fallback. Hardening, not a report of an active exploit.
Summary
default_commandforclaude-code,codex, andgemini-cliinacp_providers.pyvia module-level constants matching the agent-serverDockerfile (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._prefer_pinned_binarymatch the provider packageby name (ignoring any
@version) so the image-binary rewrite still fires forthe pinned default and for any
npxcommand a client sends (bare, pinned, ordrifted); only the native fallback carries the pin. Adds
ACPAgentSettings._npm_package_name.conversation_router_acp.py— previouslynpx -y claude-agent-acp(unscoped name, 404 on npm today, registerable byanyone → dependency-confusion footgun). Now the scoped, pinned default.
tests/sdk/test_settings.py(default-commandand native-fallback forms) and add a test asserting the version-agnostic
rewrite to the pinned binary.
Issue Number
Closes #3357
How to Test
Or by inspection:
The SDK pins and the Dockerfile
npm install -gline are now identical, sobuild-time and native runtime versions cannot diverge.
Video/Screenshots
N/A — no UI change.
Type
Notes
default_commandis a tuple ofstr; only its contents changed. Callersbuilding their own command via
ACPAgent(acp_command=[...])are unaffected.acp_providers.pyand the Dockerfilenpm install -gline; a comment on theconstants points at the Dockerfile to make that contract explicit.
@openhands/typescript-clientACPregistry 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.