Skip to content

[codex] Preserve request SecretRef markers in models.json - #84868

Closed
zr9959 wants to merge 3 commits into
openclaw:mainfrom
zr9959:codex/request-secret-markers-models-json
Closed

zr9959 wants to merge 3 commits into
openclaw:mainfrom
zr9959:codex/request-secret-markers-models-json

Conversation

@zr9959

@zr9959 zr9959 commented May 21, 2026 •

Copy link
Copy Markdown

Summary

  • Preserve SecretRef markers for nested provider request secrets when generating prompt-visible models.json, including request headers, auth token/value, TLS material, and proxy TLS material.
  • Strip request SecretRef marker strings before inline/discovered provider request config is converted into runtime transport headers/auth/TLS.
  • Apply source snapshot markers over resolved runtime values so generated agent config does not persist request-scoped plaintext secrets.
  • Extend openclaw secrets audit to flag stale generated models.json request secrets that may already exist on disk.

Why

#11829 tracks reducing agent-visible API key exposure. Current main already protects top-level provider apiKey and provider headers, but models.providers.*.request.* is also part of the documented SecretRef credential surface. Without this patch, resolved request header/auth/TLS secrets can still be serialized into models.json.

The latest review also identified a downstream risk: once request markers are written into generated models.json, the inline/discovered provider path must treat those marker strings as non-secret placeholders, not as outbound transport credentials. This update closes that consumer path.

This is a focused Layer 1 hardening PR. It does not claim to close the full roadmap while plaintext config remains supported.

Real behavior proof

  • Behavior or issue addressed: Request-scoped SecretRef markers are preserved in generated prompt-visible models.json snapshots, but are stripped before inline/discovered provider request config becomes runtime transport headers, auth, TLS, or proxy TLS values. This prevents marker placeholders such as secretref-managed and secretref-env:* from being sent as outbound credentials while still avoiding plaintext request secrets in generated config.
  • Real environment tested: Local OpenClaw repository checkout on macOS, using the real models/secrets/request transport code paths and a temporary runtime config with source SecretRef snapshot data. No live third-party credentials were used; all sensitive example values were redacted placeholders.
  • Exact steps or command run after this patch: Ran the models.json generation path with a runtime config containing request header/auth/TLS SecretRefs, then passed the generated provider request block through the runtime request sanitizer and inline provider transport attachment path. Also ran a real openclaw secrets audit --json invocation against a temporary generated models.json containing redacted plaintext request residue.
  • Evidence after fix: Copied live output from the local run showed generated request markers first, then stripped runtime transport config:
{
  "generatedRequestBlock": {
    "headers": {
      "Authorization": "secretref-env:OPENAI_REQUEST_AUTH_HEADER",
      "X-Static": "tenant-a"
    },
    "auth": {
      "mode": "authorization-bearer",
      "token": "secretref-env:OPENAI_REQUEST_BEARER"
    },
    "tls": {
      "key": "secretref-managed",
      "serverName": "api.openai.com"
    }
  },
  "sanitizedRuntimeRequestBlock": {
    "headers": {
      "X-Static": "tenant-a"
    },
    "tls": {
      "serverName": "api.openai.com"
    }
  },
  "inlineProviderTransportValues": {
    "headers": {
      "X-Static": "tenant-a"
    },
    "tls": {
      "serverName": "api.openai.com"
    }
  }
}

The audit command output against a temporary generated models.json with redacted plaintext request residue reported the expected request-secret paths:

{
  "auditCommandExitCode": 0,
  "requestSecretFindings": [
    {
      "code": "PLAINTEXT_FOUND",
      "jsonPath": "providers.openai.request.headers.Authorization",
      "severity": "warn"
    },
    {
      "code": "PLAINTEXT_FOUND",
      "jsonPath": "providers.openai.request.auth.token",
      "severity": "warn"
    },
    {
      "code": "PLAINTEXT_FOUND",
      "jsonPath": "providers.openai.request.tls.key",
      "severity": "warn"
    }
  ]
}
  • Observed result after fix: The generated config keeps SecretRef marker placeholders in request-scoped secret fields, runtime transport conversion drops those placeholders before outbound use, static non-secret request metadata remains attached, and the audit command flags stale plaintext request residue in generated models.json.
  • What was not tested: None

Validation

corepack pnpm vitest run src/agents/provider-request-config.test.ts src/agents/pi-embedded-runner/model.inline-provider.test.ts
corepack pnpm vitest run src/agents/models-config.runtime-source-snapshot.test.ts src/secrets/audit.test.ts src/agents/provider-request-config.test.ts src/agents/pi-embedded-runner/model.inline-provider.test.ts
corepack pnpm exec oxlint src/agents/provider-request-config.ts src/agents/provider-request-config.test.ts src/agents/pi-embedded-runner/model.inline-provider.test.ts
corepack pnpm run tsgo:core
corepack pnpm run tsgo:test:src
git diff --check
corepack pnpm run check:changed
corepack pnpm run test:changed

Results:

  • Targeted request transport regression tests passed: 2 files, 43 tests.
  • Related models/secrets/request tests passed: 5 files, 80 tests.
  • Oxlint passed with 0 warnings and 0 errors.
  • tsgo:core, tsgo:test:src, git diff --check, and check:changed passed.
  • test:changed ran the affected project shards and failed in two unrelated agent tests after 2021 tests passed:
    • src/agents/cli-runner.reliability.test.ts
    • src/agents/subagent-registry.announce-loop-guard.test.ts

Those two failing tests are outside the changed models/secrets/request transport paths and were previously reproduced on a clean origin/main worktree with the same assertions. The focused regression, security/config, lint, type, and changed checks for this PR pass.

Refs #11829

@zr9959
zr9959 requested a review from a team as a code owner May 21, 2026 07:17
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed June 30, 2026, 9:54 PM ET / 01:54 UTC.

Summary
The PR preserves request-scoped SecretRef markers in generated models.json, strips those marker strings before provider request transport use, and expands secrets audit coverage for request credential residue.

PR surface: Source +533, Tests +225. Total +758 across 12 files.

Reproducibility: yes. Source inspection on current main shows request SecretRefs are supported config fields, but generated models.json preservation and audit only cover apiKey/top-level headers while request sanitizer still returns marker strings as transport values.

Review metrics: 1 noteworthy metric.

  • Request credential surfaces: 4 changed: headers, auth, direct TLS, proxy TLS. The PR changes generated-config, audit, and runtime transport behavior across multiple credential-bearing request surfaces, so maintainers should review the whole boundary before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #11829
Summary: This PR is a focused candidate for the request-scoped models.json part of the open API-key exposure roadmap, with a sibling PR covering overlapping top-level provider secret persistence.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦞 diamond lobster
Patch quality: 🧂 unranked krab
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Rebase or reapply onto current src/agents/embedded-agent-runner paths.
  • Filter generated request-header audit findings to sensitive or explicitly secret headers.
  • Rerun focused request transport, models config, secrets audit, lint/type, and changed checks after rebase.

Risk before merge

  • [P1] The PR is currently CONFLICTING/DIRTY against main and still modifies the retired src/agents/pi-embedded-runner path, so it cannot land until reapplied to current src/agents/embedded-agent-runner files.
  • [P1] The PR changes a credential boundary: generated request SecretRef values become placeholders, and runtime credentials must come from active source/runtime state rather than generated models.json.
  • [P1] The new request-header audit currently treats every generated request.headers.* string as a plaintext secret, which can create misleading audit findings for safe static routing metadata.

Maintainer options:

  1. Rebase And Fix Request Header Audit (recommended)
    Reapply the branch to current main, move the inline-provider change to the embedded-agent-runner path, and filter generated request-header audit findings through a sensitive-header or explicit-secret rule.
  2. Accept Placeholder Semantics Explicitly
    Maintainers can accept the credential-boundary change after confirming generated request SecretRef values are placeholders and runtime credentials always come from active source config or resolved runtime state.
  3. Fold Into The Broader Layer 1 Work
    If the overlapping top-level provider-secret PR becomes canonical, carry this PR's request-scoped marker and transport-stripping coverage there instead of landing this stale branch directly.

Next step before merge

  • [P2] Human handling is needed because the PR is conflicting and security-sensitive; the narrow audit defect is fixable, but landing also requires rebase and credential-boundary acceptance.

Security
Needs attention: The diff reduces credential exposure, but the generated request-header audit can create misleading plaintext-secret findings for non-secret request metadata.

Review findings

  • [P2] Limit request header audit to sensitive headers — src/secrets/audit.ts:504
Review details

Best possible solution:

Rebase onto current embedded-agent-runner paths, keep the request marker preservation and transport stripping, limit generated request-header audit findings to sensitive or explicitly secret headers, then rerun focused request/config/audit validation.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection on current main shows request SecretRefs are supported config fields, but generated models.json preservation and audit only cover apiKey/top-level headers while request sanitizer still returns marker strings as transport values.

Is this the best way to solve the issue?

No, not as submitted. The direction is the right narrow Layer 1 mitigation, but the branch must be rebased to current runner paths and the request-header audit needs a sensitive-header or explicit-secret filter.

Full review comments:

  • [P2] Limit request header audit to sensitive headers — src/secrets/audit.ts:504
    This loop sends every request.headers.* value to the plaintext-secret helper. Request headers can also hold static routing metadata, and the PR proof keeps X-Static, so generated models.json audit would warn on safe headers unless this path uses the existing sensitive-header policy or another explicit secret-only rule.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7ceaf0ece350.

Label changes

Label justifications:

  • P2: This is bounded provider credential hardening with meaningful security value, but the PR is a normal review item rather than an active exploit, outage, or release emergency.
  • merge-risk: 🚨 compatibility: The PR changes generated models.json semantics and the upgrade behavior for existing request credential placeholders.
  • merge-risk: 🚨 auth-provider: The diff changes how provider request headers, auth, TLS, and proxy TLS SecretRef placeholders are preserved and stripped before outbound transport.
  • merge-risk: 🚨 security-boundary: The diff changes the boundary between prompt-visible generated model catalog data, secrets audit findings, and runtime credential material.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body includes copied after-fix live output showing generated request markers, stripped runtime and inline transport values, and audit findings with redacted placeholder data.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied after-fix live output showing generated request markers, stripped runtime and inline transport values, and audit findings with redacted placeholder data.
Evidence reviewed

PR surface:

Source +533, Tests +225. Total +758 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 8 583 50 +533
Tests 4 226 1 +225
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 809 51 +758

Security concerns:

  • [medium] Request header audit over-reports non-secret metadata — src/secrets/audit.ts:504
    Every generated models.json request header string is treated as plaintext secret residue, unlike top-level provider headers which first check likely-sensitive names; this can make openclaw secrets audit noisy for safe static headers.
    Confidence: 0.9

What I checked:

Likely related people:

  • vincentkoc: Recent current-main history includes provider request override fixes and cleanup on provider-request-config.ts, the runtime path this PR changes. (role: recent area contributor; confidence: high; commits: abec88cfab3e, 06e2614cf4a5; files: src/agents/provider-request-config.ts)
  • steipete: History shows source-managed helper splitting and the Pi-to-embedded runner refactor that this branch now needs to rebase across. (role: recent refactor and adjacent owner; confidence: medium; commits: 5c52824d3efe, bb46b79d3c14, 6719528316c0; files: src/agents/models-config.providers.source-managed.ts, src/agents/embedded-agent-runner/model.inline-provider.ts)
  • xydigit-sj: Recent current-main secrets audit history includes models.json plaintext marker classification work adjacent to this PR's audit changes. (role: recent secrets audit contributor; confidence: medium; commits: 00c9ac55d664; files: src/secrets/audit.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Velvet Crabkin

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: guards the happy path.
Image traits: location status garden; accessory lint brush; palette sunrise gold and clean white; mood celebratory; pose nestled inside a glowing shell; shell matte ceramic shell; lighting bright celebratory glints; background quiet workflow signs.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Velvet Crabkin in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@zr9959

zr9959 commented May 21, 2026

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 21, 2026
@zr9959

zr9959 commented May 21, 2026

Copy link
Copy Markdown
Author

Follow-up pushed at 791e552: split SecretRef request marker helpers into a lightweight module so request config sanitization no longer imports the heavier model auth marker module during secrets runtime suite import.\n\nFresh validation:\n- Runtime external channel regression: 2 files / 3 tests passed.\n- Related request/model/secrets regression: 9 files / 97 tests passed.\n- Targeted oxlint: 0 warnings / 0 errors.\n- tsgo:core passed.\n- tsgo:test:src passed.\n- git diff --check passed.\n- check:changed passed.\n- Real behavior proof section now passes scripts/github/real-behavior-proof-policy.mjs locally.\n\nNote: test:changed still reports failures in agents tests that reproduce on a clean origin/main worktree with the same assertions, so they are baseline failures rather than regressions from this PR.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 21, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 21, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 15, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 20, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jul 1, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: [codex] Preserve request SecretRef markers in models.json This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant