Rust Sensitive Information In Http Response
Description
This vulnerability detector identifies Rust web applications that include sensitive information in HTTP responses. When applications return JSON responses containing credentials, tokens, or other sensitive data, this creates an information disclosure risk where unauthorized users could gain access to confidential information through API responses.
Detection Strategy
• The code must import the actix_web library (or similar web framework)
• A JSON response is being created and returned to the client
• The JSON response contains arguments or data that appear to be sensitive (credentials, tokens, passwords, etc.)
• The endpoint is not specifically a credential issuance endpoint (where returning credentials would be expected behavior)
Vulnerable code example
use actix_web::{get, HttpResponse};
#[get("/profile")]
async fn profile_vulnerable() -> HttpResponse {
let api_key = std::env::var("SERVICE_API_KEY").unwrap();
// VULNERABLE: Sensitive credential serialized into response
HttpResponse::Ok().json(api_key)...✅ Secure code example
use actix_web::{get, HttpResponse};
use serde::Serialize;
#[derive(Serialize)]
struct ProfileData {
status: String,
// Include only non-sensitive fields in response
}...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.