fix: audit fix — reduce password copies in memory (v0.8.4)
- attempt_login takes Zeroizing<String> by value, eliminating the redundant Zeroizing::new(password.to_string()) that doubled the Rust-owned copy. - Clear password_entry's internal buffer immediately after extracting the password, shortening the window during which the GTK GString persists in non-zeroizable libc memory.
This commit is contained in:
+6
-3
@@ -493,6 +493,10 @@ pub fn create_greeter_window(
|
||||
let Some(user) = user else { return };
|
||||
|
||||
let password = Zeroizing::new(entry.text().to_string());
|
||||
// Clear the GTK entry's internal buffer as early as possible. GTK allocates
|
||||
// the backing `GString` via libc malloc, which `zeroize` cannot reach — the
|
||||
// best we can do is shorten the window during which it resides in memory.
|
||||
entry.set_text("");
|
||||
|
||||
let session = get_selected_session(&session_dropdown, &sessions_rc);
|
||||
let Some(session) = session else {
|
||||
@@ -502,7 +506,7 @@ pub fn create_greeter_window(
|
||||
|
||||
attempt_login(
|
||||
&user,
|
||||
&password,
|
||||
password,
|
||||
&session,
|
||||
strings,
|
||||
&state,
|
||||
@@ -953,7 +957,7 @@ fn set_login_sensitive(
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn attempt_login(
|
||||
user: &User,
|
||||
password: &str,
|
||||
password: Zeroizing<String>,
|
||||
session: &Session,
|
||||
strings: &'static Strings,
|
||||
state: &Rc<RefCell<GreeterState>>,
|
||||
@@ -992,7 +996,6 @@ fn attempt_login(
|
||||
set_login_sensitive(password_entry, session_dropdown, false);
|
||||
|
||||
let username = user.username.clone();
|
||||
let password = Zeroizing::new(password.to_string());
|
||||
let exec_cmd = session.exec_cmd.clone();
|
||||
let session_name = session.name.clone();
|
||||
let greetd_sock = state.borrow().greetd_sock.clone();
|
||||
|
||||
Reference in New Issue
Block a user