HIGH poodle attackaxumbasic auth

Poodle Attack in Axum with Basic Auth

Poodle Attack in Axum with Basic Auth — how this specific combination creates or exposes the vulnerability

A Poodle (Padding Oracle On Downgraded Legacy Encryption) attack targets systems that negotiate SSL 3.0. When an Axum service is configured to accept SSL 3.0 and uses HTTP Basic Auth, the protocol downgrade risk is compounded because the credentials are transmitted with each request. In a Poodle scenario, an attacker can force a session to use SSL 3.0 and exploit the CBC padding oracle to recover plaintext bytes, including the Base64-encoded Authorization header sent by Axum under Basic Auth. Even though Axum does not manage TLS directly, if the upstream acceptor (e.g., a Rustls/TLS listener) allows SSL 3.0, the API surface becomes vulnerable. Basic Auth places credentials in every request; if SSL 3.0 is enabled and weak ciphers are negotiated, an attacker observing or influencing network path can iteratively decrypt session cookies or the auth header itself. This combination—Axum runtime serving endpoints with Basic Auth over a negotiable protocol—creates a scenario where confidentiality of credentials is at risk when SSL 3.0 is not disabled.

Consider an OpenAPI definition that documents Basic Auth usage without mandating modern ciphers or explicitly forbidding SSL 3.0. A scan by middleBrick can detect whether the runtime endpoint negotiates SSL 3.0 and whether the Authorization header is transmitted over insecure channels. middleBrick runs 12 parallel security checks, including Encryption and Input Validation, to surface findings such as deprecated protocol usage and missing transport protections. The scanner cross-references the spec’s securitySchemes with runtime behavior, ensuring that documented Basic Auth aligns with actual cipher suite support. Findings include a risk score and remediation guidance, mapping to controls in frameworks like OWASP API Top 10 and PCI-DSS, emphasizing the need to disable SSL 3.0 and prefer TLS 1.2 or higher.

Basic Auth-Specific Remediation in Axum — concrete code fixes

To mitigate Poodle risks when using HTTP Basic Auth in Axum, disable SSL 3.0 and enforce modern TLS configurations at the transport layer. Axum applications typically rely on a TLS acceptor (such as Rustls) configured externally or via hyper with TlsAcceptor. Ensure your server configuration explicitly sets minimum protocol version to TLS 1.2 and disables legacy ciphers. Below is a concrete Axum example using hyper with Rustls to enforce secure TLS settings while protecting Basic Auth credentials.

use axum::{routing::get, Router};
use hyper::server::conn::http1;
use hyper::service::service_fn;
use hyper_util::rt::TokioIo;
use rustls::{pki_types::CertificateDer, ServerConfig};
use rustls_pemfile::{certs, pkcs8_private_keys};
use std::{fs::File, io::BufReader, sync::Arc};
use tokio::net::TcpListener;

async fn auth_middleware(req: axum::http::Request) -> Result {
    let auth_header = req.headers().get("authorization");
    match auth_header {
        Some(header_value) => {
            let header_str = header_value.to_str().unwrap_or("");
            if header_str.starts_with("Basic ") {
                // Perform validation, e.g., decode and check credentials
                let encoded = &header_str[6..];
                if let Ok(decoded) = base64::decode(encoded) {
                    if let Ok(credentials) = String::from_utf8(decoded) {
                        let parts: Vec<&str> = credentials.splitn(2, ':').collect();
                        if parts.len() == 2 && parts[0] == "user" && parts[1] == "pass" {
                            return Ok(axum::http::Response::new(axum::body::boxed(axum::body::Full::new("OK".into()))));
                        }
                    }
                }
            }
            Err((axum::http::StatusCode::UNAUTHORIZED, "Invalid credentials".into()))
        }
        None => Err((axum::http::StatusCode::UNAUTHORIZED, "Missing authorization header".into())),
    }
}

#[tokio::main]
async fn main() {
    let listener = TcpListener::bind("127.0.0.1:3000").await.unwrap();

    let config = Arc::new({
        let mut cfg = ServerConfig::builder()
            .with_no_client_auth()
            .with_single_cert(
                load_certs("cert.pem"),
                load_private_key("key.pem"),
            )
            .unwrap();
        cfg.versions = vec![rustls::version::TLS12, rustls::version::TLS13];
        cfg
    });

    let make_svc = service_fn(|stream| {
        let config = config.clone();
        async move {
            let tls = rustls::server::TlsServer::new(config, stream);
            let io = TokioIo::new(tls.await.unwrap());
            let service = service_fn(auth_middleware).layer(axum::middleware::from_fn(auth_middleware));
            http1::Builder::new().serve_connection(io, service).unwrap();
        }
    });

    http1::Builder::new().serve_connection(listener, make_svc).unwrap();
}

fn load_certs(path: &str) -> Vec> {
    let file = &mut BufReader::new(File::open(path).unwrap());
    certs(file).unwrap().into_iter().map(CertificateDer::from).collect()
}

fn load_private_key(path: &str) -> rustls::pki_types::PrivateKeyDer<'static> {
    let file = &mut BufReader::new(File::open(path).unwrap());
    let mut keys = pkcs8_private_keys(file).unwrap();
    keys.remove(0).into()
}

This code disables SSL 3.0 by setting cfg.versions to TLS 1.2 and TLS 1.3 only, ensuring that Poodle’s protocol downgrade vector is not available. The middleware validates the Basic Auth header on each request, decoding and checking credentials without logging or exposing them. middleBrick can validate that the runtime configuration aligns with the declared securitySchemes and flag any endpoints that still permit SSL 3.0 or use weak ciphers. Remediation guidance from a scan will include disabling SSL 3.0, rotating credentials if exposure is suspected, and adopting token-based alternatives where feasible.

Frequently Asked Questions

Does middleBrick fix Poodle findings in Axum endpoints using Basic Auth?
middleBrick detects and reports Poodle-related findings, including SSL 3.0 usage and missing transport protections for Basic Auth. It provides remediation guidance but does not fix, patch, block, or remediate issues directly.
Can middleBrick validate that Basic Auth credentials are protected against protocol downgrade in Axum?
Yes. By cross-referencing OpenAPI security schemes with runtime encryption checks, middleBrick can identify whether SSL 3.0 is enabled and whether credentials are transmitted over insecure channels, mapping findings to OWASP API Top 10 and PCI-DSS controls.