Skip to content

fix: reject generic Control Spine secret markers - #539

Closed
YoneRai12 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-control-spine-client
Closed

fix: reject generic Control Spine secret markers#539
YoneRai12 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-control-spine-client

Conversation

@YoneRai12

Copy link
Copy Markdown
Owner

Motivation

  • Control Spine の成功レスポンスやエラーディテールをそのまま公開レポートに含める際、既存のマーカー拒否リストが session_tokentokenbearersecret などの汎用的なトークン名を含まず、情報漏洩を許していたため fail-closed にする必要があった。

Description

  • 公開ペイロード/エラーテキスト向けの禁止マーカーを PUBLIC_PAYLOAD_FORBIDDEN_MARKERS に集約して拡張し、authorizationsession_tokentokenbearersecret 等を追加して汎用的なトークン名を拒否するようにした(clients/cli/yonerai_cli/services/control_spine_service.py に追加)。
  • _safe_text_assert_public_safe_payload をこの集中マーカーで判定するように切り替え、成功時の body やエラー由来の文字列の出力を fail-closed にした。
  • 回帰テストを追加して、/v1/statussession_token が混入した場合、/v1/rate-limittoken が混入した場合、エラー詳細に Bearer ... のような文字列が入る場合にそれぞれ拒否されることを検証するテストを追加した(tests/test_control_spine_client.py にテスト追加)。
  • 変更ファイル: clients/cli/yonerai_cli/services/control_spine_service.py, tests/test_control_spine_client.py(新規テスト追加・既存ロジックの小修正)。

Testing

  • 実行した自動検証: PYTHONPATH=clients/cli pytest -q tests/test_control_spine_client.py::test_status_rejects_generic_session_token_payload tests/test_control_spine_client.py::test_rate_limit_rejects_generic_token_payload tests/test_control_spine_client.py::test_error_detail_rejects_bearer_secret_text tests/test_control_spine_client.py::test_rate_limit_rejects_unexpected_token_fields tests/test_control_spine_client.py::test_control_spine_rejects_private_or_token_payload — 5 tests 全て成功。
  • その他チェック: git diff --check, python -m compileall(対象ファイル)、ruff check、秘密/ローカルパス・hidden-Unicode スキャン を実施し合格。
  • 完全なテストスイート(PYTHONPATH=clients/cli pytest -q tests/test_control_spine_client.py)は既存の別件で 1 件失敗(test_expired_session_mid_command_has_guided_japanese_relogin が期待値 auth_state == "expired" を満たさず unauthenticated を返すことが事前に存在する既知の不一致)で、今回のセキュリティ回帰変更自体は新規テストを含めて合格している。

注記: コミット 5dada16(ヘッド)にて実装し、PR タイトルは fix: reject generic Control Spine secret markers です。ランタイム境界は CLI 公開ペイロードのフィルタのみで、src/cogs/ora.pyreference_clawdbot、プロダクションシークレットなどは触れていません。


Codex Task

@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: fb2c06e5c7

ℹ️ 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 +45 to +47
"bearer",
"secret",
"token",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve auth errors that mention tokens

When an authenticated Control Spine call gets a 401/403 whose JSON detail says invalid token or Bearer ..., _safe_request now asserts the raw error payload before _error_from_status can map the status to staging_auth_required; because these new markers match that routine auth text, the CLI returns control_spine_private_payload_rejected with no status code or yonerai login guidance. This affects saved-session expiry/revocation paths such as yonerai whoami; the error detail should be sanitized/dropped without bypassing the status-based auth handling.

Useful? React with 👍 / 👎.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the forbidden payload markers in 'control_spine_service.py' by extracting them into a single global constant 'PUBLIC_PAYLOAD_FORBIDDEN_MARKERS' and adding new markers such as 'authorization', 'bearer', 'secret', and 'token'. It also adds corresponding unit tests to verify that payloads containing these sensitive markers are properly rejected. The feedback suggests improving the IP address markers by removing the hardcoded 'http://' prefix to also catch 'https' connections, and considering the addition of the '172.16.0.0/12' private IP range.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +53 to +56
"http://10.",
"http://192.168.",
"http://127.",
"169.254.169.254",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

セキュリティマーカーを改善する提案です。

現在のマーカーリストでは、http://10. のように http:// がハードコードされているため、https を使用したプライベートIPへのURLを見逃す可能性があります。

169.254.169.254 のマーカーと同様にプロトコル部分を削除し、IPアドレスのプレフィックスのみをマーカーとすることで、httphttps の両方に対応でき、より堅牢になります。

また、プライベートIPアドレス範囲 172.16.0.0/12 が欠けている点も、将来的に考慮すると良いかもしれません。

Suggested change
"http://10.",
"http://192.168.",
"http://127.",
"169.254.169.254",
"10.",
"192.168.",
"127.",
"169.254.169.254",

@YoneRai12

Copy link
Copy Markdown
Owner Author

superseded by #557 on current main (b745e30). The valid security finding from this PR was reimplemented in the canonical current-main patch with regression tests and Quality Wall passing. Closing this duplicate to keep one canonical security baseline.

@YoneRai12 YoneRai12 closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant