Closed kris7t closed 3 years ago
Thank you for pointing this out. I decided to roll my own fix because I don't like this part of int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
syscall:
If pathname is absolute, then dirfd is ignored.
Allowing fstat
ing anything on filesystem.
I also tried restricting fstatat
with seccomp rule like this:
rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 3,
SCMP_A0(SCMP_CMP_EQ, fd),
SCMP_A1(SCMP_CMP_EQ, (scmp_datum_t)buf),
SCMP_A2(SCMP_CMP_LE, BUF_SIZE));
To allow only empty string (""
) as second fstatat
argument, but as that empty string is passed as pointer I could only compare it to that pointer (which is random). More explanation in article Deep argument inspection for seccomp on lwm.net
Starting with glibc 2.33, wob crashes due to a SIGSYS signal immediately after reading the first line of input:
A small test program without Seccomp confirms that the
newfstatat
system call is now used byfgets
giving rise to the following system call trace: