Poodle Attack in Axum with Cockroachdb
Poodle Attack in Axum with Cockroachdb — 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 with CBC-mode ciphers and reveal padding errors through timing or error messages. In an Axum service that routes API calls to CockroachDB via TLS, the vulnerability arises when the application or a downstream proxy accepts SSL 3.0 or does not enforce TLS 1.2+ consistently. Axum itself does not implement TLS, so the risk depends on the runtime environment (e.g., hyper, Rustls, OpenSSL via acceptor configuration) and any proxy or load balancer in front of the service.
When an Axum server communicates with CockroachDB using a TLS connection that allows SSL 3.0 or weak ciphers, an attacker who can position themselves on the network (e.g., same LAN or via a compromised proxy) may downgrade the negotiated protocol to SSL 3.0 and perform chosen-ciphertext padding oracles. CockroachDB supports TLS for client connections, and if the server certificate chain uses CBC ciphersuites and SSL 3.0 is not disabled, the oracle becomes exploitable. An attacker can iteratively manipulate encrypted requests—potentially crafted to include sensitive metadata or tokens—and observe differences in error responses or timing to decrypt information or bypass intended access controls.
In Axum, this often surfaces when middleware or configuration permits legacy protocols, or when TLS settings are inherited from an upstream proxy or Kubernetes ingress that does not enforce modern standards. For example, a Rustls acceptor configured with default ciphersuites may include CBC-based options, and if SSLv3 or TLS 1.0/1.1 are not explicitly disabled, an attacker can force a downgraded connection. The combination of Axum’s flexible runtime and CockroachDB’s TLS-enabled PostgreSQL wire protocol means that an SSL 3.0 downgrade on the database link can expose padding-oracle behavior that leaks authentication tokens or session cookies. This maps to the OWASP API Security Top 10 controls around encryption and authentication, and may intersect with findings in the Encryption and Authentication checks performed by middleBrick.
Cockroachdb-Specific Remediation in Axum — concrete code fixes
Remediation centers on enforcing modern TLS and disabling SSL 3.0 for any connection involving CockroachDB. In Axum, this is typically achieved by configuring the underlying Rustls (or OpenSSL) acceptor or client builder used to connect to the database. Below are concrete examples for both server-side (Axum with Rustls) and client-side (Axum connecting to CockroachDB) configurations.
1) Axum server side (Rustls acceptor)
Configure Rustls to use only secure protocols and ciphersuites, explicitly disabling SSLv3, TLS 1.0, and TLS 1.1.
use axum::Server;
use rustls::{Certificate, PrivateKey, ServerConfig};
use rustls_pemfile::{certs, pkcs8_private_keys};
use std::fs::File;
use std::io::BufReader;
use std::net::SocketAddr;
use std::sync::Arc;
async fn start_axum_secure() {
// Load server cert and key
let cert_file = &mut BufReader::new(File::open("cert.pem").unwrap());
let key_file = &mut BufReader::new(File::open("key.pem").unwrap());
let cert_chain: Vec<Certificate> = certs(cert_file).unwrap().into_iter().map(Certificate).collect();
let mut keys: Vec<PrivateKey> = pkcs8_private_keys(key_file).unwrap().into_iter().map(PrivateKey).collect();
let mut server_config = ServerConfig::builder()
.with_safe_defaults()
.with_no_client_auth()
.with_single_cert(cert_chain, keys.remove(0))
.expect("invalid certificate or key");
// Explicitly disable legacy protocols
server_config.versions = vec![rustls::ProtocolVersion::TLSv1_2, rustls::ProtocolVersion::TLSv1_3];
// Ensure no CBC ciphersuites if not required; safe_defaults excludes weak ciphers, but verify
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
Server::bind(&addr)
.tls_rustls(Arc::new(server_config))
.serve(axum::routing::get(|| async { "OK" }).into_make_service_with_connect_info::<SocketAddr>())
.await
.unwrap();
}
2) Axum connecting to CockroachDB (TLS client)
When Axum opens a connection to CockroachDB, enforce TLS 1.2+ and disable SSL 3.0 in the client builder.
use cockroach_client::CockroachDb;
use rustls::{ClientConfig, ProtocolVersion};
use std::sync::Arc;
async fn connect_cockroachdb_secure() {
let mut client_config = ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(vec![])
.expect("valid root store")
.with_no_client_auth();
// Enforce TLS 1.2 and TLS 1.3 only; SSLv3, TLS 1.0, TLS 1.1 are not included in safe_defaults
client_config.versions = vec![ProtocolVersion::TLSv1_2, ProtocolVersion::TLSv1_3];
let tls = Arc::new(client_config);
let db = CockroachDb::new(
"postgresql://root@localhost:26257/defaultdb?sslmode=require",
tls,
)
.await
.expect("failed to connect with enforced TLS");
// Use db for operations
}
3) Infrastructure and proxy considerations
If Axum sits behind a load balancer or ingress (e.g., Kubernetes Ingress, Envoy), ensure those components also disable SSL 3.0 and restrict ciphers. For example, in an Envoy filter or HAProxy configuration, explicitly set protocols to TLSv1.2 and TLSv1.3. Additionally, rotate certificates and prefer ECDHE key exchange with strong ciphers to mitigate oracle risks. These steps reduce the attack surface and prevent protocol downgrade that enables Poodle-style exploits.