Rust Diesel Plaintext Storage Of Password
Description
Detects when password fields are stored in plaintext within Rust applications using the Diesel ORM framework. The vulnerability occurs when sensitive password data is inserted into the database without proper hashing or encryption, exposing user credentials to potential data breaches.
Detection Strategy
• Code must import both 'diesel' and 'actix_web' libraries
• Code must contain a function call that acts as a Diesel values sink (typically database insertion operations)
• One of the function arguments must be identified as a password field based on naming patterns or context
• The password argument must be passed in an unsafe manner (without hashing or encryption)
Vulnerable code example
use diesel::prelude::*;
use diesel::PgConnection;
#[derive(Insertable)]
#[diesel(table_name = users)]
struct NewUser {
username: String,
password: String, // Plain text password field...✅ Secure code example
use bcrypt::{hash, DEFAULT_COST};
use diesel::prelude::*;
use diesel::PgConnection;
#[derive(Insertable)]
#[diesel(table_name = users)]
struct NewUser {
username: String,...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.