From 723cadaff0ac2140754376f73f53662fbf8d9d3f Mon Sep 17 00:00:00 2001 From: wz Date: Fri, 19 May 2023 19:41:14 +0300 Subject: [PATCH 1/2] Ignore key codes over 0xf000 on insert --- services/keyboard/src/main.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/services/keyboard/src/main.rs b/services/keyboard/src/main.rs index 82cc6af3d..fc4e478fb 100644 --- a/services/keyboard/src/main.rs +++ b/services/keyboard/src/main.rs @@ -938,18 +938,22 @@ fn main() -> ! { #[cfg(all(feature="debuginject", not(feature="rawserial")))] if let Some(conn) = listener_conn { if key != '\u{0000}' { - log::info!("injecting key '{}'({:x})", key, key as u32); // always be noisy about this, it's an exploit path - xous::try_send_message(conn, - xous::Message::new_scalar(listener_op.unwrap(), - key as u32 as usize, - '\u{0000}' as u32 as usize, - '\u{0000}' as u32 as usize, - '\u{0000}' as u32 as usize, - ) - ).unwrap_or_else(|_| { - log::info!("Input overflow, dropping keys!"); - xous::Result::Ok - }); + if key > '\u{f000}' { + log::info!("ignoring key '{}'({:x})", key, key as u32); // ignore macOS weird characters + } else { + log::info!("injecting key '{}'({:x})", key, key as u32); // always be noisy about this, it's an exploit path + xous::try_send_message(conn, + xous::Message::new_scalar(listener_op.unwrap(), + key as u32 as usize, + '\u{0000}' as u32 as usize, + '\u{0000}' as u32 as usize, + '\u{0000}' as u32 as usize, + ) + ).unwrap_or_else(|_| { + log::info!("Input overflow, dropping keys!"); + xous::Result::Ok + }); + } } } From e08f4b89c55531179f9a12546d36b459ed13ec75 Mon Sep 17 00:00:00 2001 From: wz Date: Sun, 21 May 2023 14:00:52 +0300 Subject: [PATCH 2/2] Narrow down the exclude list to Apple PUA characters --- services/keyboard/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/keyboard/src/main.rs b/services/keyboard/src/main.rs index fc4e478fb..1c555bccd 100644 --- a/services/keyboard/src/main.rs +++ b/services/keyboard/src/main.rs @@ -938,8 +938,8 @@ fn main() -> ! { #[cfg(all(feature="debuginject", not(feature="rawserial")))] if let Some(conn) = listener_conn { if key != '\u{0000}' { - if key > '\u{f000}' { - log::info!("ignoring key '{}'({:x})", key, key as u32); // ignore macOS weird characters + if key >= '\u{f700}' && key <= '\u{f8ff}' { + log::info!("ignoring key '{}'({:x})", key, key as u32); // ignore Apple PUA characters } else { log::info!("injecting key '{}'({:x})", key, key as u32); // always be noisy about this, it's an exploit path xous::try_send_message(conn,