aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2020-05-30 21:56:18 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2020-05-30 22:06:15 +0200
commita2a704492b9f4d2408d180f7aeeacf4c789a1d67 (patch)
treedddf8c868f1ef40c017140ed35018c7aef8b64d8
parent0f8b40652bca0670f1f0bda069bbc55f8b5e364d (diff)
downloadst-patched-a2a704492b9f4d2408d180f7aeeacf4c789a1d67.tar.bz2
st-patched-a2a704492b9f4d2408d180f7aeeacf4c789a1d67.tar.xz
st-patched-a2a704492b9f4d2408d180f7aeeacf4c789a1d67.zip
config.def.h: add an option allowwindowops, by default off (secure)
Similar to the xterm AllowWindowOps option, this is an option to allow or disallow certain (non-interactive) operations that can be insecure or exploited. NOTE: xsettitle() is not guarded by this because st does not support printing the window title. Else this could be exploitable (arbitrary code execution). Similar problems have been found in the past in other terminal emulators. The sequence for base64-encoded clipboard copy is now guarded because it allows a sequence written to the terminal to manipulate the clipboard of the running user non-interactively, for example: printf '\x1b]52;0;ZWNobyBoaQ0=\a'
-rw-r--r--config.def.h4
-rw-r--r--st.c2
-rw-r--r--st.h1
3 files changed, 6 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h
index 293e00c..6f05dce 100644
--- a/config.def.h
+++ b/config.def.h
@@ -43,6 +43,10 @@ static unsigned int tripleclicktimeout = 600;
43/* alt screens */ 43/* alt screens */
44int allowaltscreen = 1; 44int allowaltscreen = 1;
45 45
46/* allow certain non-interactive (insecure) window operations such as:
47 setting the clipboard text */
48int allowwindowops = 0;
49
46/* 50/*
47 * draw latency range in ms - from new content/keypress/etc until drawing. 51 * draw latency range in ms - from new content/keypress/etc until drawing.
48 * within this range, st draws when content stops arriving (idle). mostly it's 52 * within this range, st draws when content stops arriving (idle). mostly it's
diff --git a/st.c b/st.c
index 2d901ab..ef8abd5 100644
--- a/st.c
+++ b/st.c
@@ -1861,7 +1861,7 @@ strhandle(void)
1861 xsettitle(strescseq.args[1]); 1861 xsettitle(strescseq.args[1]);
1862 return; 1862 return;
1863 case 52: 1863 case 52:
1864 if (narg > 2) { 1864 if (narg > 2 && allowwindowops) {
1865 dec = base64dec(strescseq.args[2]); 1865 dec = base64dec(strescseq.args[2]);
1866 if (dec) { 1866 if (dec) {
1867 xsetsel(dec); 1867 xsetsel(dec);
diff --git a/st.h b/st.h
index d978458..3d351b6 100644
--- a/st.h
+++ b/st.h
@@ -118,6 +118,7 @@ extern char *stty_args;
118extern char *vtiden; 118extern char *vtiden;
119extern wchar_t *worddelimiters; 119extern wchar_t *worddelimiters;
120extern int allowaltscreen; 120extern int allowaltscreen;
121extern int allowwindowops;
121extern char *termname; 122extern char *termname;
122extern unsigned int tabspaces; 123extern unsigned int tabspaces;
123extern unsigned int defaultfg; 124extern unsigned int defaultfg;