Prevent "screen scraping", disable DECRQCRA (#7701)
* Security fix: prevent screen scraping Problem ------- DECRQCRA was added in6cbb3ba43, for9702d1cf5(esctest integration) Sunday, March 17 2019. Six days later, March 23 2019, although esctest was removed inc93f967bc, DECRQCRA remained enabled by default for all WezTerm releases since. March 2023, @j4james mentioned WezTerm has this option enabled by default https://github.com/microsoft/terminal/issues/14974, "some people consider it a security risk" September 2023, https://dgl.cx/2023/09/ansi-terminal-security#cursor-checksum article writes, "using DECRQCRA [..] potential attack here is reading what is displayed on the terminal before a user SSHes to a remote system." By switching to "alternate screen", it also possible to recover last TUI display, such as contents of the file last opened in an editor. Example CLI script scrapes screens '0' and '1' of WezTerm, https://github.com/jquast/blessed/blob/master/bin/screen-scrape.py Solution -------- Disable https://vt100.net/docs/vt510-rm/DECRQCRA.html by default, may be re-enabled by configuration. --- Refs: https://github.com/wezterm/wezterm/pull/7701 Co-authored-by: Wez Furlong <wez@wezfurlong.org>
This commit is contained in:
1 parent
05343b3870
commit
577474d89e
5 files changed
+27
-8
No files matched your search
@@ -260,6 +260,12 @@ pub struct Config {
|
||||
#[dynamic(default)]
|
||||
pub enable_title_reporting: bool,
|
||||
|
||||
/// Whether the terminal should respond to DECRQCRA checksum requests.
|
||||
/// Disabled by default as it allows programs to read screen contents.
|
||||
/// <https://vt100.net/docs/vt510-rm/DECRQCRA.html>
|
||||
#[dynamic(default)]
|
||||
pub enable_checksum_rectangular_area: bool,
|
||||
|
||||
/// Specifies the width of a new window, expressed in character cells
|
||||
#[dynamic(default = "default_initial_cols", validate = "validate_row_or_col")]
|
||||
pub initial_cols: u16,
|
||||
|
||||
@@ -82,6 +82,10 @@ impl wezterm_term::TerminalConfiguration for TermConfig {
|
||||
self.configuration().enable_title_reporting
|
||||
}
|
||||
|
||||
fn enable_checksum_rectangular_area(&self) -> bool {
|
||||
self.configuration().enable_checksum_rectangular_area
|
||||
}
|
||||
|
||||
fn enable_kitty_keyboard(&self) -> bool {
|
||||
self.configuration().enable_kitty_keyboard
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ usually the best available version.
|
||||
As features stabilize some brief notes about them will accumulate here.
|
||||
|
||||
#### Changed
|
||||
* DECRQCRA is now disabled by default to prevent silent screen scraping.
|
||||
Set `enable_checksum_rectangular_area = true` to re-enable it.
|
||||
Thanks to @jquast! #7701
|
||||
* Wayland: currently being reimplemented, it maybe more unstable than usual.
|
||||
Please file GH issues for any problems you see.
|
||||
Many thanks to @tzx and @tmccombs! #4777 #5781
|
||||
|
||||
@@ -220,6 +220,10 @@ pub trait TerminalConfiguration: Downcast + std::fmt::Debug + Send + Sync {
|
||||
false
|
||||
}
|
||||
|
||||
fn enable_checksum_rectangular_area(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn log_unknown_escape_sequences(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
@@ -2073,14 +2073,16 @@ impl TerminalState {
|
||||
right,
|
||||
..
|
||||
} => {
|
||||
let checksum = self.checksum_rectangle(
|
||||
left.as_zero_based(),
|
||||
top.as_zero_based(),
|
||||
right.as_zero_based(),
|
||||
bottom.as_zero_based(),
|
||||
);
|
||||
write!(self.writer, "\x1bP{}!~{:04x}\x1b\\", request_id, checksum).ok();
|
||||
self.writer.flush().ok();
|
||||
if self.config.enable_checksum_rectangular_area() {
|
||||
let checksum = self.checksum_rectangle(
|
||||
left.as_zero_based(),
|
||||
top.as_zero_based(),
|
||||
right.as_zero_based(),
|
||||
bottom.as_zero_based(),
|
||||
);
|
||||
write!(self.writer, "\x1bP{}!~{:04x}\x1b\\", request_id, checksum).ok();
|
||||
self.writer.flush().ok();
|
||||
}
|
||||
}
|
||||
Window::ResizeWindowCells { .. } => {
|
||||
// We don't allow the application to change the window size; that's
|
||||
|
||||
Reference in new issue
Block a user