Skip to content

Commit 5487f54

Browse files
fix: open redirection (#926)
check to match the base uri and the redirect uri to confirm that the redirect uri has not been tampered and stop leaking the sensitive information such as authentication tokens or session cookies
1 parent 19212de commit 5487f54

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

server/src/handlers/http/oidc.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ pub async fn login(
6363
req: HttpRequest,
6464
query: web::Query<RedirectAfterLogin>,
6565
) -> Result<HttpResponse, OIDCError> {
66+
let conn = req.connection_info();
67+
let base_url = format!("{}://{}/", conn.scheme(), conn.host());
68+
if !base_url.eq(query.redirect.as_str()) {
69+
return Err(OIDCError::BadRequest);
70+
}
6671
let oidc_client = req.app_data::<Data<DiscoveredClient>>();
6772
let session_key = extract_session_key_from_req(&req).ok();
6873
let (session_key, oidc_client) = match (session_key, oidc_client) {

0 commit comments

Comments
 (0)