fix(core/ui): fix non-BMP glyph aliasing
What changed, and why it matters
This commit fixes a display bug in Trezor hardware wallets where special Unicode characters above U+FFFF (so-called supplementary plane characters) were incorrectly drawn as completely different, ordinary characters. For example, a rare character U+10041 could appear on screen as the letter 'A'. Because the device signs the original bytes but the user sees a misleading string, an attacker could craft a transaction or message that looks legitimate to the user while actually signing something different. The fix now shows a non-printable placeholder for such characters instead of the wrong glyph.
Treat this as a security-relevant UI-rendering fix. Verify the patched firmware on real devices for non-BMP strings, ensure the nonprintable glyph is clearly distinguishable, and consider broader Unicode normalization/homograph defenses in signing prompts. Users should upgrade firmware once a release containing this commit is available.
Security signals we found
UI spoofing / homograph-style attack via glyph aliasing
User-visible string differs from signed bytes
Silent integer truncation of Unicode code point
Changelog explicitly labeled as .security
Regression test added for non-BMP aliasing
Evidence from the diff
In core/embed/rust/src/ui/display/font.rs, get_glyph_data previously accepted a u16 codepoint derived via ch as u16, which silently truncated characters outside the Basic Multilingual Plane (BMP). A supplementary-plane code point such as U+10041 was reduced to U+0041 (‘A’), causing visually identical rendering for distinct byte sequences. The patch changes get_glyph_data to take a char, attempts u16::try_from(ch), and returns the font’s glyph_nonprintable for any non-BMP character. A regression test verifies that every non-BMP character sharing low 16 bits with ASCII or NBSP renders as the nonprintable glyph rather than aliasing.
Changed components
Trezor Core firmware UI renderingcore/embed/rust/src/ui/display/font.rsGlyph lookup / font rendering subsystemInspect captured patch +23 / −2
### core/.changelog.d/+unicode_non_bmp_aliasing.security
@@ -0,0 +1 @@
+Fix characters above U+FFFF being displayed as unrelated characters.
### core/embed/rust/src/ui/display/font.rs
@@ -192,11 +192,15 @@ impl GlyphData {
'\u{00a0}' => '\u{0020}',
c => c,
};
- let gl_data = self.get_glyph_data(ch as u16);
+ let gl_data = self.get_glyph_data(ch);
Glyph::load(gl_data)
}
- fn get_glyph_data(&self, codepoint: u16) -> &[u8] {
+ fn get_glyph_data(&self, ch: char) -> &[u8] {
+ let Some(codepoint) = u16::try_from(ch).ok() else {
+ return self.font.glyph_nonprintable;
+ };
+
if codepoint >= ' ' as u16 && codepoint < 0x7F {
// ASCII character
let offset = codepoint - ' ' as u16;
@@ -636,4 +640,20 @@ mod tests {
text
);
}
+
+ #[test]
+ fn get_glyph_supplementary_plane_is_nonprintable() {
+ // A char outside the BMP (Basic Multilingual Plane) must not alias
+ // the BMP glyph sharing its low 16 bits (e.g. U+10041 rendering as 'A').
+ let nonprintable = super::Glyph::load(FONT.glyph_nonprintable).data;
+ FONT.with_glyph_data(|data| {
+ assert_ne!(data.get_glyph('A').data, nonprintable);
+ for plane in 1..=16 {
+ for low in (u32::from(' ')..=u32::from('~')).chain([0xa0]) {
+ let ch = unwrap!(char::from_u32((plane << 16) | low));
+ assert_eq!(data.get_glyph(ch).data, nonprintable, "{ch:?}");
+ }
+ }
+ });
+ }
}Why this scored 74/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.