Skip to content

fix(gateway): redact secrets in skills.update response#69998

Merged
hxy91819 merged 4 commits into
openclaw:mainfrom
Ziy1-Tan:fix/skills-update-redact-response-66769
Apr 27, 2026
Merged

fix(gateway): redact secrets in skills.update response#69998
hxy91819 merged 4 commits into
openclaw:mainfrom
Ziy1-Tan:fix/skills-update-redact-response-66769

Conversation

@Ziy1-Tan

@Ziy1-Tan Ziy1-Tan commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

skills.update was returning the full updated SkillConfig entry — including plaintext apiKey and env values — in the RPC response. This could leak credentials into:

  • Control UI WebSocket traffic
  • Client logs
  • Session transcripts

Fix

Pass the response config through the existing redactConfigObject() utility before returning it. This reuses the same redaction infrastructure used by config.get, which already handles all sensitive paths via isSensitiveConfigPath() (apiKey, token, password, secret, etc.).

Config is still written to disk in full — only the RPC response payload is redacted.

Diff surface: +2 lines in production code (1 import, 1 call site).

Testing

  • Existing test: strips embedded CR/LF from apiKey — still passes, config written correctly
  • New test: redacts apiKey and secret env values from the response but writes full values to config
    • Verifies apiKey is redacted in response
    • Verifies secret-named env key (GEMINI_API_KEY) is redacted in response
    • Verifies non-secret env key (BRAVE_REGION) is still returned
    • Verifies full values are still persisted to config file

AI Transparency

  • 🤖 AI-assisted
  • Testing depth: fully tested (2 targeted unit tests)
  • All generated code reviewed and understood

Fixes #66769

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Apr 22, 2026
@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a credential-leak bug in skills.update by wrapping the RPC response config in the existing redactConfigObject() utility, mirroring the approach already used by config.get. The fix is minimal (+2 lines), well-tested, and correctly leverages pattern-based guessing (since no uiHints are provided) to redact fields such as apiKey and any env.* keys whose names match sensitive patterns (e.g. GEMINI_API_KEY).

Confidence Score: 5/5

Safe to merge — the redaction logic is correct and the only finding is a minor test assertion style issue.

The production change is a single, well-understood call to an already-proven utility. All remaining feedback is P2 (weak test assertion style) and does not block merge.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/gateway/server-methods/skills.update.normalizes-api-key.test.ts
Line: 91-95

Comment:
**Weak redaction assertions allow false positives**

The `.not.toBe()` checks pass for any value other than the plaintext secret — including `undefined`, `null`, or an empty string — so a bug that silently drops the `apiKey` key or replaces it with `null` would not be caught. Asserting the exact sentinel value would make these tests meaningfully verify the redaction contract.

```suggestion
    expect(config.apiKey).toBe("__OPENCLAW_REDACTED__");
    const env = config.env as Record<string, string>;
    expect(env.GEMINI_API_KEY).toBe("__OPENCLAW_REDACTED__");
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "chore(changelog): add entry for skills.u..." | Re-trigger Greptile

Comment thread src/gateway/server-methods/skills.update.normalizes-api-key.test.ts Outdated

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

Copy link
Copy Markdown
Contributor

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: 986fb542d7

ℹ️ 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/gateway/server-methods/skills.ts
@Ziy1-Tan

Copy link
Copy Markdown
Contributor Author

cc @hxy91819 .

@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group knowing-oarfish-aymf

Title: Open PR duplicate: [Bug]: skills.update echoes raw apiKey and env secrets in gateway response

Number Title
#66928 fix(gateway): redact apiKey and secret env values in skills.update response
#66986 fix: mask secrets in skills.update response
#69998* fix(gateway): redact secrets in skills.update response

* This PR

@steipete steipete left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the right canonical fix for #66769: using redactConfigObject(current) is better than local hand-rolled masking because it covers nested config, SecretRef-shaped values, and sensitive-path heuristics consistently with the rest of config reads.

One repo-policy blocker before merge: this dropped the changelog entry in the last commit. Please add a single-line CHANGELOG.md entry under the active ### Fixes section with attribution, e.g. Thanks @Ziy1-Tan, and keep the exact sentinel assertions you added in the test.

@Ziy1-Tan
Ziy1-Tan force-pushed the fix/skills-update-redact-response-66769 branch 2 times, most recently from 986fb54 to 485f53f Compare April 26, 2026 07:16
@Ziy1-Tan
Ziy1-Tan requested a review from steipete April 26, 2026 07:16

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

Copy link
Copy Markdown
Contributor

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: 485f53f4ca

ℹ️ 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/gateway/server-methods/skills.ts
@Ziy1-Tan
Ziy1-Tan force-pushed the fix/skills-update-redact-response-66769 branch 2 times, most recently from 3565d61 to 14992e8 Compare April 26, 2026 13:18
@clawsweeper

clawsweeper Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Codex automated review: keeping this open.

Keep this PR open. Current main still returns the updated skills.update config object directly, so the linked credential-echo bug remains unfixed on main. The latest PR head is a focused implementation candidate and now addresses the previously raised redacted-sentinel round-trip concern; related duplicate PRs are closed unmerged, and the canonical bug remains open.

Best possible solution:

Keep this PR open. The best path is to finish review on the current head, resolve or explain the failing checks, then land the focused gateway change plus regression tests so it closes #66769. The latest PR head is a better candidate than closing/reopening duplicate attempts because it fixes the main leak and preserves existing secrets when clients round-trip redacted sentinel values.

What I checked:

Remaining risk / open question:

  • The current PR head is not ready to land without CI follow-up: GitHub check-runs report failures in checks-node-core and checks-node-agentic-plugins on 61fc06f33f29804dcc1c3ec90cbd66f1946df714.
  • This is a security-sensitive response-shaping change; before merge, maintainers should ensure the failing checks are unrelated or fixed and that the new regression tests run in the intended changed lane.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against a35ad200d1d1.

@Ziy1-Tan
Ziy1-Tan force-pushed the fix/skills-update-redact-response-66769 branch from 14992e8 to 94d979d Compare April 27, 2026 02:48
@hxy91819 hxy91819 self-assigned this Apr 27, 2026
@Ziy1-Tan
Ziy1-Tan force-pushed the fix/skills-update-redact-response-66769 branch from 94d979d to 12d7073 Compare April 27, 2026 07:13
@hxy91819
hxy91819 force-pushed the fix/skills-update-redact-response-66769 branch from 12d7073 to b75062a Compare April 27, 2026 07:15
Ziy1-Tan and others added 3 commits April 27, 2026 16:12
skills.update was returning the full updated SkillConfig entry including
plaintext apiKey and env values in the RPC response. This could leak
credentials into Control UI WebSocket traffic, client logs, or session
transcripts.

Fix by passing the response config through the existing redactConfigObject()
utility, which already handles all sensitive paths (apiKey, tokens, passwords,
secret-named env keys, etc.) via isSensitiveConfigPath(). Config is still
written to disk in full — only the response payload is redacted.

Fixes openclaw#66769
Use __OPENCLAW_REDACTED__ sentinel value instead of .not.toBe() to
properly verify the redaction contract — weak negation checks would
pass even if the field were silently dropped or set to null.
@hxy91819
hxy91819 force-pushed the fix/skills-update-redact-response-66769 branch from 98b1b04 to 8dae600 Compare April 27, 2026 08:13
@hxy91819

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🚀

ℹ️ 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".

@hxy91819
hxy91819 merged commit 27ee5c0 into openclaw:main Apr 27, 2026
64 of 66 checks passed
@hxy91819

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @Ziy1-Tan!

ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
Merged via squash.

Prepared head SHA: 61fc06f
Co-authored-by: Ziy1-Tan <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Merged via squash.

Prepared head SHA: 61fc06f
Co-authored-by: Ziy1-Tan <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
Merged via squash.

Prepared head SHA: 61fc06f
Co-authored-by: Ziy1-Tan <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: 61fc06f
Co-authored-by: Ziy1-Tan <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Merged via squash.

Prepared head SHA: 61fc06f
Co-authored-by: Ziy1-Tan <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Merged via squash.

Prepared head SHA: 61fc06f
Co-authored-by: Ziy1-Tan <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: skills.update echoes raw apiKey and env secrets in gateway response

3 participants