Repository navigation
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
I have a Rocky Linux 8 installation with powershell 7.1.4. I use powershell for monitoring and run pwsh to get a set of results. I've added opt-out environment variables as following to the systemd.
systemctl edit zabbix-server
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_telemetry?view=powershell-7.1
https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry
[Service]
Environment=POWERSHELL_TELEMETRY_OPTOUT=1
Environment=DOTNET_TELEMETRY_OPTOUT=1
Environment=POWERSHELL_CLI_TELEMETRY_OPTOUT=1
Environment=DOTNET_CLI_TELEMETRY_OPTOUT=1
printenv gives me the optout parameters as expected when verifying.
printenv
LANG=en_US.UTF-8
INVOCATION_ID=69a4bad5f0c14cf4b291504873445d19
PWD=/
JOURNAL_STREAM=9:66980
CONFFILE=/etc/zabbix/zabbix_server.conf
POWERSHELL_CLI_TELEMETRY_OPTOUT=1
DOTNET_TELEMETRY_OPTOUT=1
DOTNET_CLI_TELEMETRY_OPTOUT=1
SHLVL=1
POWERSHELL_TELEMETRY_OPTOUT=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
_=/usr/bin/printenv
Related issues would be running ps1 script create temp file in everytime #11599 and PowerShell ignoring telemetry opt-out options, tries to call home regularly #10005
Expected behavior
Expecting powershell to run without telemetry, not trying to gather data that selinux denies for the user.Actual behavior
Each run of powershell generates a folder in /tmp/ as following;
04ad7c7a-7fd1-4465-9b31-38b83f70fcc1/
.cache/powershell/StartupProfileData-NonInteractive
15661dc5-9fdc-42ed-bf20-12d902193070/
30544f3e-6e5b-47d2-be8d-e2518802caa3/
.....
Each time a powershell script is run with the service user, selinux gives loads of denied events like the following;
#tail -f /var/log/audit/audit.log | grep denied
.......
type=AVC msg=audit(1631798453.792:11014): avc: denied { getattr } for pid=5141 comm=506970656C696E6520457865637574 path="/usr/sbin/lvm" dev="dm-0" ino=492056 scontext=system_u:system_r:zabbix_t:s0 tcontext=system_u:object_r:lvm_exec_t:s0 tclass=file permissive=0
type=AVC msg=audit(1631798453.792:11016): avc: denied { getattr } for pid=5141 comm=506970656C696E6520457865637574 path="/usr/bin/rpm" dev="dm-0" ino=50624503 scontext=system_u:system_r:zabbix_t:s0 tcontext=system_u:object_r:rpm_exec_t:s0 tclass=file permissive=0
type=AVC msg=audit(1631798453.792:11017): avc: denied { getattr } for pid=5141 comm=506970656C696E6520457865637574 path="/usr/bin/gpg" dev="dm-0" ino=50706017 scontext=system_u:system_r:zabbix_t:s0 tcontext=system_u:object_r:gpg_exec_t:s0 tclass=file permissive=0
type=AVC msg=audit(1631798453.792:11018): avc: denied { getattr } for pid=5141 comm=506970656C696E6520457865637574 path="/usr/bin/dnf-3" dev="dm-0" ino=50725090 scontext=system_u:system_r:zabbix_t:s0 tcontext=system_u:object_r:rpm_exec_t:s0 tclass=file permissive=0
type=AVC msg=audit(1631798453.792:11020): avc: denied { getattr } for pid=5141 comm=506970656C696E6520457865637574 path="/usr/bin/sudo" dev="dm-0" ino=50755282 scontext=system_u:system_r:zabbix_t:s0 tcontext=system_u:object_r:sudo_exec_t:s0 tclass=file permissive=0
type=AVC msg=audit(1631798453.792:11021): avc: denied { getattr } for pid=5141 comm=506970656C696E6520457865637574 path="/usr/bin/hostname" dev="dm-0" ino=50800802 scontext=system_u:system_r:zabbix_t:s0 tcontext=system_u:object_r:hostname_exec_t:s0 tclass=file permissive=0
.......Error details
No response
Environment data
> uname -a
Linux 4.18.0-305.17.1.el8_4.x86_64 #1 SMP Wed Sep 8 16:42:05 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
> dnf list installed | grep powershell
powershell.x86_64 7.1.4-1.rhel.7 @packages-microsoft-com-prodVisuals
No response
Activity
237dmitry commentedon Sep 17, 2021
I think this is distribution related issue. Nothing like this do reproduce in my linux environment.
Zimeon- commentedon Sep 17, 2021
What OS and do you have selinux enabled?
PaulHigin commentedon Sep 21, 2021
WG-Security
This is an engine telemetry issue.
PaulHigin commentedon Oct 4, 2021
WG-Security
Keith Hill (@rkeithhill) Travis Plunk (@TravisEz13) and I looked at this and it appears to be a telemetry issue and not a security issue. Why are you adding the security working group?
rkeithhill commentedon Oct 4, 2021
Misunderstanding on my part. Sorry.
daxian-dbw commentedon Oct 15, 2021
The reported issue is not related to telemetry.
This is because the environment variable
Homeis not defined. PowerShell needs to create a few cache folders (e.g. .cache, .local) under$Home, and when the environment variableHomeis not defined or has an empty value, PowerShell will create a temporary folder and consider that as the user home directory. This is why you see those folders with GUID names.This should be fixed. We partially fixed the issue before (see #13239), where we make sure only 1 temporary folder is used within a pwsh session, but that didn't solve the problem when many pwsh sessions start and end quickly. We should fix that too.
This is likely due to the policy of SELinux.
According to this article, the
"{ getattr }"means that someone tried tostat()the file. In this case, the file's attributes were looked up first (or at least, the operation tried to look them up), couldn't get those attributes and gave up. And the"path=/usr/sbin/lvm"is the path to the object you tried to perform an operation on -- it could be a command resolution (searching executables in PATH) triggered by a command invocation.daxian-dbw commentedon Oct 15, 2021
Actually, this is a duplicate of #15299 😄
yusufozturk commentedon May 4, 2022
Dongbo Wang (@daxian-dbw) thanks for the resolution.
I feel like telemetry shouldn't be enabled by default. For example related to this issue, our customer added values but didn't work out in PowerShell 7.2.2. It generates thousands of telemetry files and it fills up the disk and generates IO on the server.
I kindly ask opinions of James Truher (@JamesWTruher) and Aditya Patwardhan (@adityapatwardhan) about the telemetry behaviour. I don't think majority of the people will ever use these files and it already caused some issues for now, so that makes me think "if someone needs telemetry in the future, they should enable the telemetry".
daxian-dbw commentedon May 4, 2022
Yusuf Ozturk (@yusufozturk) As explained in #16112 (comment), the folders created in
/tmpare not because of telemetry. WhenPOWERSHELL_TELEMETRY_OPTOUT=1is set, no telemetry will be sent out.The tons-of-temp-folder issue was resolved by #16263
inoperable commentedon Sep 28, 2022
pwsh.exe is calling, for example, a23-79-157-152.deploy.static.akamaitechnologies.com despite all of flags. Its just ridiculous how ms is handling it. I asked already before about that - and was answered some other component of .net is doing that... so which one? 5 years ago I asked about the installer flag being set by default to opt in - they fucking still didn't managed to build a installer in which this is opted out by default :-)