summaryrefslogtreecommitdiffstats
path: root/sysif.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-04-09 06:18:46 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-04-09 06:18:46 -0700
commit02b83600e20bbf7c61e09c9ad40ff35433da0c74 (patch)
tree4f98524019c22c1855e9622cf304524caceff407 /sysif.h
parentdd23b426d1a5c1790a4886201628476bf73fe7b8 (diff)
downloadtxr-02b83600e20bbf7c61e09c9ad40ff35433da0c74.tar.gz
txr-02b83600e20bbf7c61e09c9ad40ff35433da0c74.tar.bz2
txr-02b83600e20bbf7c61e09c9ad40ff35433da0c74.zip
repl: improve dotfile security tests.
We test the .txr_history file for bad permissions also, not only .txr_profile. Though commands are not automatically executed out of .txr_history, a user could execute a harmful command due to not noticing the malicious modification. An additional useful diagnostic is added: if a dotfile is found to have the wrong permission, it's possible that this is due to a poor umask setting. We check for a weak umask and warn the user. Note: the .txr_history check doesn't use the open stream, therefore it is vulnerable to TOCTTOU race condition: the file looks good, but between the time we verify this and open the file to load it, the file has been replaced by a malicious one. * parser.c (report_security_problem): New static function, factored out of load_rcfile. Includes umask test. (load_rcfile): Call report_security_problem if the .txr_profile is writable to others. Also, no need to call stat any more; the path testing function now takes a stream argument. (repl): Check .txr_history for inappropriate writepermissions also and call report_security_problem if so. * sysif.c (umask_wrap): Change static function to external linkage. * sysif.c (umask_wrap): Declaration updated.
Diffstat (limited to 'sysif.h')
-rw-r--r--sysif.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/sysif.h b/sysif.h
index c2a650c0..08349e5b 100644
--- a/sysif.h
+++ b/sysif.h
@@ -48,6 +48,7 @@ val num_time(time_t time);
#if HAVE_SYS_STAT
struct stat;
val stat_to_struct(struct stat st, val path);
+val umask_wrap(val mask);
#endif
val stat_wrap(val path);
val stdio_ftell(FILE *);