googleapis / googleapis/google-http-java-client

Core: Validate header names and values to prevent CRLF injection

オープン 初心者向け
#2,180 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
1.4k
フォーク
473
PR マージ指標
30日以内にマージされた PR はありません

説明

Environment details

1. Core - HttpHeaders in google-http-client
2. OS type and version: Any
3. Java version: Any (Java 8+)
4. google-http-client version: 2.1.1 and earlier

---

Problem Statement

HttpHeaders does not validate header names or values for carriage return (\r) or line feed (\n) characters. If untrusted input is passed into header names or values, an attacker can inject CRLF sequences leading to HTTP Response Splitting or Header Injection.

---

Steps to reproduce

1. Create a HttpHeaders instance with a header name or value containing \r\n.
2. Serialize headers into a low-level HTTP request using HttpHeaders.serializeHeaders(...).
3. Observe that the injected header line is accepted without error.

---

Proposed Fix

Reject header names or values containing CRLF in HttpHeaders.addHeader():

if (name.contains("\r") || name.contains("\n") || stringValue.contains("\r") || stringValue.contains("\n")) {
throw new IllegalArgumentException("Header name or value contains CRLF characters.");
}

Regression tests (testSerializeHeaders_crlfInjectionInName and testSerializeHeaders_crlfInjectionInValue) are included in the accompanying PR.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start in HttpHeaders.addHeader() and trace how headers reach HttpHeaders.serializeHeaders(...). Run the named regression tests, testSerializeHeaders_crlfInjectionInName and testSerializeHeaders_crlfInjectionInValue, or add them if they are not present. Done means CRLF-containing names and values are rejected while valid headers still serialize successfully.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
security
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
78/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。