fix: reject generic Control Spine secret markers - #539
Conversation
There was a problem hiding this comment.
💡 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".
| "bearer", | ||
| "secret", | ||
| "token", |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
| "http://10.", | ||
| "http://192.168.", | ||
| "http://127.", | ||
| "169.254.169.254", |
There was a problem hiding this comment.
セキュリティマーカーを改善する提案です。
現在のマーカーリストでは、http://10. のように http:// がハードコードされているため、https を使用したプライベートIPへのURLを見逃す可能性があります。
169.254.169.254 のマーカーと同様にプロトコル部分を削除し、IPアドレスのプレフィックスのみをマーカーとすることで、http と https の両方に対応でき、より堅牢になります。
また、プライベートIPアドレス範囲 172.16.0.0/12 が欠けている点も、将来的に考慮すると良いかもしれません。
| "http://10.", | |
| "http://192.168.", | |
| "http://127.", | |
| "169.254.169.254", | |
| "10.", | |
| "192.168.", | |
| "127.", | |
| "169.254.169.254", |
Motivation
session_token、token、bearer、secretなどの汎用的なトークン名を含まず、情報漏洩を許していたため fail-closed にする必要があった。Description
PUBLIC_PAYLOAD_FORBIDDEN_MARKERSに集約して拡張し、authorization、session_token、token、bearer、secret等を追加して汎用的なトークン名を拒否するようにした(clients/cli/yonerai_cli/services/control_spine_service.pyに追加)。_safe_textと_assert_public_safe_payloadをこの集中マーカーで判定するように切り替え、成功時のbodyやエラー由来の文字列の出力を fail-closed にした。/v1/statusにsession_tokenが混入した場合、/v1/rate-limitにtokenが混入した場合、エラー詳細に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.pyやreference_clawdbot、プロダクションシークレットなどは触れていません。Codex Task