Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predictable /tmp file in stats.c allows for local denial of service #13

Open
wfrisch opened this issue Sep 2, 2024 · 1 comment
Open

Comments

@wfrisch
Copy link

wfrisch commented Sep 2, 2024

Summary

In smc-tools [1][2], the open_cache_file() function in stats.c [3] operates on a predictable path in /tmp, allowing an unprivileged local user to deny the program's service.

sprintf(cache_file_path, "/tmp/.smcstats.u%d", getuid());
fd = open(cache_file_path, O_RDWR|O_CREAT|O_NOFOLLOW, 0600);

Implications

  1. Symlink attacks are not possible here due to O_NOFOLLOW, but open() will fail, causing a denial of service.
  2. If /proc/sys/fs/protected_regular = 0, an attacker can place a file with arbitrary content which will be read by smcr stats. However, since the parser is correctly implemented, there appears to be no obvious way to exploit this with bogus data.
  3. If /proc/sys/fs/protected_regular = 2, open() will fail, causing a denial of service.

Suggested mitigation

The data should be stored in the user's home directory or /run/user/${UID}/.

[1] https://build.opensuse.org/package/show/network/smc-tools
[2] https://github.com/ibm-s390-linux/smc-tools
[3]

sprintf(cache_file_path, "/tmp/.smcstats.u%d", getuid());

@JanKarcher
Copy link

Hello,
thanks for bringing this up and sending out a reminder.
I'm going to look into this and update the issue accordingly.

  • Jan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants