Skip to content

[WRONG BRANCH] fix(grok): require per-model ownership markers - #398

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-grok-model-deletion-vulnerability
Draft

[WRONG BRANCH] fix(grok): require per-model ownership markers#398
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-grok-model-deletion-vulnerability

Conversation

@luvs01

@luvs01 luvs01 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A provider-inheritance migration unintentionally treated model_provider = "opencodex" plus a predictable ocx-<id> alias as deletion authority for outside-fence model tables, allowing a configured upstream to cause user-authored model tables to be removed.
  • The change restores a conservative safety boundary: inheriting a managed provider no longer grants teardown權; a durable per-model marker is required to classify a model as explicitly owned.

Description

  • Change orphan classification in findOpencodexOrphans so provider inheritance alone does not mark an outside-fence [model.*] as owned, and require a per-model durable marker (x-opencodex-grok = "1") or the legacy fingerprint to declare explicit ownership.
  • Stop folding provider-owned ids into model ownership logic and remove the deterministic-alias+provider explicit-ownership branch so only a model-local marker (or legacy generated fingerprint) permits deletion.
  • Emit the durable marker on every generated model table in buildGrokManagedBlock so generated models remain removable even if Grok re-serializes them outside the fence while preserving the shared model_providers.opencodex provider block.
  • Update tests to cover the hardening and new marker behavior in tests/grok-orphan-adoption.test.ts, tests/grok-config-inject.test.ts, and tests/grok-attribution.test.ts.

Testing

  • Ran the focused Grok suite with bun test tests/grok-orphan-adoption.test.ts tests/grok-config-inject.test.ts tests/grok-attribution.test.ts, which passed (focused run: 105 tests, 0 failures).
  • Ran bun run typecheck and bun run privacy:scan, both of which succeeded on the environment used for the change.
  • The full repository test run was not used as the primary gate due to unrelated environment/concurrency failures observed in other suites; focused tests and typecheck were used to validate this focused security fix.
  • Note: a system Bun (v1.2.x) lacked node:zlib.zstdDecompressSync and failed the focused run; the repository-provided Bun (v1.4.0) was used to produce the green focused test results above.

Codex Task

@coderabbitai

coderabbitai Bot commented Aug 31, 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: Pro Plus

Run ID: aaad45ae-ec13-4358-a7aa-8ff7109dd8c3


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 Aug 31, 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-08-31T01:17:15.723079Z 7575048 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 added the bug Something isn't working label Aug 31, 2026
@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@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: 7575048c7a

ℹ️ 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 thread src/grok/inject.ts
? "explicit"
: "legacy";
if (!hasOwnershipMarker && !legacyGenerated && !inheritedOwned) continue;
if (!hasOwnershipMarker && !legacyGenerated) continue;

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 Restore endpoint checks before adopting legacy Grok models

When an unmarked user table has the legacy-looking alias/name/backend shape and its model ID is emitted by the current catalog, this condition now classifies it as a legacy orphan without checking api_key or base_url. A normal Grok sync will therefore delete and replace even a user-authored remote model such as [model.ocx-gpt-5-6-sol] with api_backend = "chat_completions", name = "OCX gpt-5.6-sol", a remote URL, and a user secret, losing its custom settings. Keep the former OpenCodex-key and loopback-URL checks for the legacyGenerated path, while allowing only the durable per-model marker to bypass them.

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

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Aug 31, 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(grok): require per-model ownership markers [WRONG BRANCH] fix(grok): require per-model ownership markers Aug 31, 2026
@github-actions
github-actions Bot marked this pull request as draft August 31, 2026 01:18
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