Skip to content

fix(redact): cover more credential keys and inline sk- API keys (#16) - #165

Open
RupeshMaster wants to merge 1 commit into
CodewithJha:mainfrom
RupeshMaster:fix/redaction-key-coverage
Open

RupeshMaster wants to merge 1 commit into
CodewithJha:mainfrom
RupeshMaster:fix/redaction-key-coverage

Conversation

@RupeshMaster

@RupeshMaster RupeshMaster commented Nov 27, 2026 •

Copy link
Copy Markdown

Summary

Closes #16. redact_secrets only knew eight exact key names, so common credential shapes reached Hosted SQLite, ingest uploads and test reports unredacted.

  • Keys from the issue: openai_api_key, client_secret, private_key and x-api-key / x_api_key are now [REDACTED].
  • How: apikey, secret_key and private_key join the exact list, and a key is also sensitive when it ends in _ + a covered name. That covers the whole family (anthropic_api_key, stripe_secret_key, github_token, db_password) instead of four names. Lookalikes are left alone and tested: max_tokens, total_tokens, token_count, public_key, secret_question, password_hint, idempotency_key.
  • Key normalization now treats any separator like - ("api key", x.api.key), and APIKey / apikey are covered.
  • Inline pattern (the optional item): OpenAI-style sk-… / sk-proj-… keys inside strings are redacted. The pattern needs a word boundary, 20+ key characters and at least one digit, so prose such as sk-learn-compatible-estimators or task-1234… is untouched.
  • SECURITY.md covered-keys table updated. MUTINY_DISABLE_SECRET_REDACTION behavior is unchanged; no new dependency.

Decision to review

The suffix rule goes a little beyond the four names in the issue. It can over-redact a harmless key such as next_page_token in displayed evidence (policy evaluation still runs on raw data, so results are unaffected). If you prefer the exact list only, I can drop the suffix rule and keep the named keys.

The issue is assigned to @CodewithJha with no activity since September, so I went ahead; if you already have work in progress on it, feel free to close this.

Type of change

Checklist

  • I read CONTRIBUTING.md (where to ask, how reviews work, how to run tests)
  • Linked related issue (Fixes #N) or Discussion when applicable
  • Core stays free of framework SDK imports (adapters own glue)
  • Tests added or updated when behavior changes (uv run pytest tests/unit -q)
  • Docs / README claims match reality (no PyPI / multi-adapter claims unless shipped)
  • One concern per PR when possible
  • Authorized testing only — no open-internet attack-proxy behavior

Test plan

  • Python lint: uv run --locked ruff check → all checks passed
  • Backend tests: uv run pytest tests/unit tests/integration tests/reliability -q → 884 passed, including tests/unit/test_secret_redaction.py and tests/integration/test_secret_redaction_persist.py. Run locally on Python 3.12 only (macOS, OPENAI_API_KEY unset); 3.11 is left for CI.
  • CLI smoke: from a copy of examples/openai_support_agent, mutiny --help, mutiny init, mutiny run with MUTINY_SAMPLE_OFFLINE=1 and empty OPENAI_API_KEY / FEATHERLESS_API_KEY → violation found, regression saved.
  • Web typecheck + build: not run; apps/web is not touched.
  • Package build + isolated artifact gate: tests/unit/test_package_release.py passed as part of the unit run; ./scripts/verify_release_artifacts.sh not run.

Extra: 36 new unit cases (key variants, lookalikes, sk- keys, prose) and the persist test now carries the new keys and an inline sk-proj- key through SQLite, the API and the CLI report. 24 of the redaction tests fail on main (ee7e898). Existing tests are unchanged and pass, including the ordinary-prose case.

Notes

redact_secrets only knew eight exact key names, so common shapes passed
through to Hosted SQLite, ingest uploads and test reports unredacted:
openai_api_key, client_secret, private_key, x-api-key, apikey, and
free-text sk-proj-... keys.

- Add apikey, secret_key and private_key, and treat a key as sensitive
  when it ends in a covered name (openai_api_key, x-api-key,
  client_secret, github_token, db_password). Lookalikes such as
  max_tokens, public_key and secret_question are left alone.
- Normalize any separator in key names, not only hyphens.
- Redact OpenAI-style sk- keys inside strings; the pattern needs 20+ key
  characters including a digit so prose like sk-learn is kept.

Closes CodewithJha#16
@vercel

vercel Bot commented Nov 27, 2026

Copy link
Copy Markdown

@RupeshMaster is attempting to deploy a commit to the priyanshu's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: expand secret redaction key set and inline API-key patterns

1 participant