Skip to content

[WRONG BRANCH] fix(opencode-go): bound replayed tool promotion - #470

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-opencode-go-adapter
Draft

[WRONG BRANCH] fix(opencode-go): bound replayed tool promotion#470
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-opencode-go-adapter

Conversation

@luvs01

@luvs01 luvs01 commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A normalizer unconditionally promoted every additional_tools declaration from expanded continuation input into the top-level tools catalog, which allowed historical (replayed) hosted tools to be treated as current-turn authority.
  • The adapter invoked the normalizer without passing replay provenance (_replayPrefixLen), and canonical OpenCode Go requests default to explicit stateless replay, making the regression exploitable on continuation-cache hits.

Description

  • Add a replayPrefixLength parameter to normalizeOpenCodeGoAdditionalTools and compute a currentTurnStart boundary so only additional_tools at or after the replay boundary are promoted to the top-level tools array. (src/adapters/opencode-go-additional-tools.ts).
  • Pass the parsed replay prefix (parsed._replayPrefixLen) when calling the normalizer from the Responses passthrough adapter so the helper can distinguish historical wrappers. (src/adapters/openai-responses.ts).
  • Add a focused regression test that simulates a two-turn continuation and asserts that additional_tools restored from history are removed but not promoted when the current request supplies an explicit empty catalog. (tests/providers/opencode-go-grok46-responses.test.ts).
  • Small wiring/test helper adjustments to propagate _replayPrefixLen into the adapter test harness.

Testing

  • Ran the focused regression suite: bun test tests/providers/opencode-go-grok46-responses.test.ts (39 passed, 0 failed).
  • Ran typecheck: bun run typecheck (passed).
  • Ran privacy scan: bun run privacy:scan (passed).
  • The repository-wide test run was started but encountered unrelated environment/CI failures in other server API tests; the focused tests and static checks for this change passed.

Codex Task

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 21a20c9d-ac5f-4566-aaac-28a4a1e9ab39


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-09T04:23:02.043514Z b75da6e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions github-actions Bot changed the title fix(opencode-go): bound replayed tool promotion [WRONG BRANCH] fix(opencode-go): bound replayed tool promotion Sep 9, 2026
@github-actions
github-actions Bot marked this pull request as draft September 9, 2026 04:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b75da6e7dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +27 to +29
const currentTurnStart = Number.isFinite(replayPrefixLength)
? Math.min(body.input.length, Math.max(0, Math.trunc(replayPrefixLength)))
: 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the replay boundary aligned after stateless repairs

When a replay prefix contains a dangling function call before an additional_tools item, the OpenCode Go stateless path first runs repairOrphanedInputItems at src/adapters/openai-responses.ts:2387-2389, inserting a synthetic output and shifting that historical wrapper right while _replayPrefixLen remains unchanged. This index comparison then treats a wrapper shifted to the boundary as current and promotes its tools, leaving the historical-tool authority bug reachable; carry or adjust the provenance through length-changing transforms, or normalize before them.

AGENTS.md reference: src/AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant