Bugs in `Authorization: Bearer …` header parsing
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- rust
調査の方向性
Start at the headers::authorization::Bearer implementation and run the test_invalid_auth_header example from the issue. Check parsing of malformed values, restricted token characters, extra spaces, and case-insensitive auth schemes; done means invalid headers fail and valid tokens are returned without surrounding whitespace.
索引モデルが issue の本文から書いたものです。
説明
The following test exposes a few issues in headers::authorization::Bearer:
#[cfg(test)]
mod tests {
#[test]
fn test_invalid_auth_header() {
// Malformed, should not parse.
let value = http::HeaderValue::from_str("Bearer foo, Bearer bar").unwrap();
use headers::authorization::Credentials;
let decoded = headers::authorization::Bearer::decode(&value);
println!("decoded = {:?}", decoded);
println!("if decoded succeeded, the token was: {:?}", decoded.as_ref().map(|b| b.token()));
// The header is malformed, so parsing should fail:
assert!(decoded.is_none());
}
}
Basically, Bearer's implementation will strip the leading string "Bearer " from the value, and return the remainder for as a token. This isn't valid according to the grammar for the Bearer authn scheme. (The grammar of the token itself is restricted to a certain set of characters, for example.) In fact, the code only checks that the header starts with Bearer in debug mode (as it is done w/ a debug_assert!), so in a release build, any value will parse, including, e.g., Basic <a basic headers' credentials>.
Even where the header is valid, and should parse, the .token() determines the token by simply removing "Bearer ".len() characters from the front of the header value, which itself is not correct: Bearer foobar (n.b., the double space; this is permitted by the grammar for the header, but is not part of the token) parses as it should, but .token() returns " foobar".
Last, the debug-mode-only debug_assert! asserts that the value starts with Bearer — but auth schemes in HTTP are case insensitive, so this too will reject valid inputs. (Note: the Basic auth-scheme parser shares its own version of this issue, too.)
- 主要言語
- Rust
- スター
- 200
- フォーク
- 107
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hyperium/headers のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
Link support オープン
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
hyperium/headers の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
bug good first issue package: quic
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
-
`dora trace view` sends a non-canonical full UUID as-is, so a valid trace ID shows "No spans found" オープンcli coordinator rust
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
area: tasks enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Jason-jo17/Polybench#15 · コメント 1 件 ·