Skip to content

ClientError::JwksFetch の error_description に内部エラー詳細が露出する問題を修正する #188

@coderabbitai

Description

@coderabbitai

概要

HTTPクライアントのビルド失敗時、内部エラーの詳細が ClientError::JwksFetch のペイロードを通じてクライアントへ返却されています。

問題箇所

ファイル: src/presentation/extractor/claims.rs (Line 171)

.map_err(|e| ClientError::JwksFetch(format!("failed to build HTTP client: {e}")))?;

IntoResponse の実装により、ClientError::JwksFetch に格納した文字列はレスポンスの error_description フィールドにそのまま含まれてしまいます。内部エラーの詳細(スタックトレースや設定情報など)が外部に漏洩するリスクがあります。

修正方針

  • クライアントへ返すメッセージは固定文言に変更する
  • 内部エラーの詳細はサーバー側のログ(tracing 等)でのみ記録する
-.map_err(|e| ClientError::JwksFetch(format!("failed to build HTTP client: {e}")))?;
+.map_err(|_| ClientError::JwksFetch("failed to build HTTP client".to_string()))?;

関連リンク


Requested by @hiterm

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions