We received a bug report (phrased as a security issue) for a program, which stated that when the program creates files on disk, it does not first verify if a symbolic link exists at the file path to be created. Because of that, an attacker may create a symbolic link, which the program (when ran by another user) may try to overwrite, thus overwriting a file that the attacker may not otherwise have write access to.
To illustrate, here is an example with gcc, which is also "vulnerable" to this problem:
- Eve sends Alice a .tar.gz file containing a C program. Inside the archive is
evil.c
, anda.out
, which is a symbolic link to/home/alice/.xinitrc
. - Under some pretense, Eve asks Alice to compile the program (and do nothing else).
- Eve runs
gcc evil.c
, which by itself should be safe (barring buffer overflows etc. in the compiler). gcc
(technically the linker) will try to write the resulting binary toa.out
, thus overwriting Alice's.xinitrc
.- Next time Alice starts her X server, Eve's code runs.
In our case, the situation is very much like gcc - the program creates files only under the current directory (unless told otherwise), with predictable names, and does not by itself execute any code from its input.
Is this something that programs such as compilers need to worry about?