7698ddb46fe62d8824a1c27419b45aefbbc70313 — Hiltjo Posthuma 4 years ago ddeed2f
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

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'
3 files changed, 6 insertions(+), 1 deletions(-)

M config.def.h
M st.c
M st.h
M config.def.h => config.def.h +4 -0
@@ 43,6 43,10 @@ static unsigned int tripleclicktimeout = 2000;
/* alt screens */
int allowaltscreen = 1;

/* allow certain non-interactive (insecure) window operations such as:
   setting the clipboard text */
int allowwindowops = 0;

 * draw latency range in ms - from new content/keypress/etc until drawing.
 * within this range, st draws when content stops arriving (idle). mostly it's

M st.c => st.c +1 -1
@@ 1929,7 1929,7 @@ strhandle(void)
		case 52:
			if (narg > 2) {
			if (narg > 2 && allowwindowops) {
				dec = base64dec(strescseq.args[2]);
				if (dec) {

M st.h => st.h +1 -0
@@ 121,6 121,7 @@ extern char *stty_args;
extern char *vtiden;
extern wchar_t *worddelimiters;
extern int allowaltscreen;
extern int allowwindowops;
extern char *termname;
extern unsigned int tabspaces;
extern unsigned int defaultfg;