Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actix Path Normalization can lead to crashes with empty replies #3562

Open
ju6ge opened this issue Jan 31, 2025 · 0 comments
Open

Actix Path Normalization can lead to crashes with empty replies #3562

ju6ge opened this issue Jan 31, 2025 · 0 comments

Comments

@ju6ge
Copy link

ju6ge commented Jan 31, 2025

Using actix path normalization together with a handler that expects the requested path as part of its parameters will lead to crashes and empty server replies.

thread 'actix-rt|system:0|arbiter:0' panicked at /home/judge/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-router-0.5.3/src/de.rs:225:5:
byte index 12 is out of bounds of `/uaie/iuaei`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Minimal example to reproduce the bug.

use actix_web::{middleware, web, App, HttpResponse, HttpServer};


async fn handler(path: web::Path<String>) -> HttpResponse {
    HttpResponse::Ok().body(format!("Responding to {path}"))
}

#[actix_web::main]
async fn main() {
    let _ = HttpServer::new(move || {
        let app = App::new()
            .service(
                web::scope("{tail:.*}")
                    .wrap(middleware::NormalizePath::default())
                    .default_service(web::to(handler))
            );
        app
    }).bind(("localhost", 8080)).unwrap().run().await;
}

Example request:

curl http://localhost:8080/uaie//iuaei

Expected behavior

The handler always receives the normalized path as its input.

Your Environment

Rust Version:
cargo 1.84.0

Actix Web Version: 4.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant