fix(auth): return_url の schemes / opaque / backslash を拒否#151
Conversation
The previous filter accepted url-parseable inputs whose Host was empty, which lets through "javascript:alert(1)" and "/\evil.com" — the former is opaque (Host empty) and the latter normalizes differently in browsers than url.Parse expects, both classic open-redirect vectors. Require the input to start with a single "/" and reject any URL whose Scheme, Host, or Opaque is set. Assisted-by: Claude (model: claude-opus-4-7)
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
概要
return_urlは単一の/で始まる文字列のみ許可し、//や/\は拒否する。Scheme/Host/Opaqueのいずれかが non-empty な URL も拒否対象とする。これでjavascript:alert(1)やmailto:...も通らなくなる。背景
従来のフィルタは
url.Parse後にHostが non-empty かどうかしか確認していなかった。古典的な open-redirect ベクタが 2 種類通過していた:javascript:alert(1)—url.Parseは Host を空にしてOpaqueに格納するため、フィルタを通過していた。/\evil.com/path— 一部のブラウザは backslash を/に正規化し、protocol-relative URL として解釈してevil.comにリダイレクトする。url.Parseの挙動とは一致しない。いずれもログイン成功後に
/login?return_url=...を経由してユーザーを攻撃者の origin に飛ばす経路として悪用できる状態だった。確認項目
TestSanitizeReturnURLを含む)。curl -i "localhost:8080/login?return_url=javascript:alert(1)"→ form action / hidden field の値が/になり、payload が出力されないこと。