Azure / Azure/azure-linux-extensions

AKVVM: akvvm_service does not start due to SeLinux problem

Open
#1,127 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
333
Forks
278
Avg merge
2d 9h
Merged PRs (30d)
4

Description

When starting `akvvm_service.service` the service crashes with the following error:
```sh
[root@test3 ~]# systemctl status akvvm_service.service
● akvvm_service.service - Key Vault VM Extension
Loaded: loaded (/etc/systemd/system/akvvm_service.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2020-06-08 11:53:40 UTC; 2min 9s ago
Process: 29203 ExecStart=/var/lib/waagent/Microsoft.Azure.KeyVault.KeyVaultForLinux-1.0.1172.13/akvvm_service (code=exited, status=203/EXEC)
Main PID: 29203 (code=exited, status=203/EXEC)

Jun 08 11:53:39 test3 systemd[1]: akvvm_service.service: Main process exited, code=exited, status=203/EXEC
Jun 08 11:53:39 test3 systemd[1]: akvvm_service.service: Failed with result 'exit-code'.
Jun 08 11:53:40 test3 systemd[1]: akvvm_service.service: Service RestartSec=100ms expired, scheduling restart.
Jun 08 11:53:40 test3 systemd[1]: akvvm_service.service: Scheduled restart job, restart counter is at 5.
Jun 08 11:53:40 test3 systemd[1]: Stopped Key Vault VM Extension.
Jun 08 11:53:40 test3 systemd[1]: akvvm_service.service: Start request repeated too quickly.
Jun 08 11:53:40 test3 systemd[1]: akvvm_service.service: Failed with result 'exit-code'.
Jun 08 11:53:40 test3 systemd[1]: Failed to start Key Vault VM Extension.
```

The reason seems to be a SeLinux problem:

```sh
[root@test3 ~]# sealert -l "*"
Hash: akvvm_service,init_t,var_log_t,file,create

SELinux is preventing /usr/lib/systemd/systemd from execute_no_trans access on the file /var/lib/waagent/Microsoft.Azure.KeyVault.KeyVaultForLinux-1.0.1172.13/akvvm_service.

***** Plugin catchall (100. confidence) suggests **************************

If you believe that systemd should be allowed execute_no_trans access on the akvvm_service file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c '(_service)' --raw | audit2allow -M my-service
# semodule -X 300 -i my-service.pp

Additional Information:
Source Context system_u:system_r:init_t:s0
Target Context system_u:object_r:var_lib_t:s0
Target Objects /var/lib/waagent/Microsoft.Azure.KeyVault.KeyVault
ForLinux-1.0.1172.13/akvvm_service [ file ]
Source (_service)
Source Path /usr/lib/systemd/systemd
Port
Host test3
Source RPM Packages systemd-239-18.el8_1.5.x86_64
Target RPM Packages
Policy RPM selinux-policy-3.14.3-20.el8.noarch
Selinux Enabled True
Policy Type targeted
Enforcing Mode Enforcing
Host Name test3
Platform Linux test3 4.18.0-147.8.1.el8_1.x86_64 #1 SMP Thu
Apr 9 13:49:54 UTC 2020 x86_64 x86_64
Alert Count 22
First Seen 2020-06-08 10:28:52 UTC
Last Seen 2020-06-08 11:53:39 UTC
Local ID b21ff411-c810-4c2e-af68-2b83c7f23071

Raw Audit Messages
type=AVC msg=audit(1591617219.884:710): avc: denied { execute_no_trans } for pid=29203 comm="(_service)" path="/var/lib/waagent/Microsoft.Azure.KeyVault.KeyVaultForLinux-1.0.1172.13/akvvm_service" dev="sda2" ino=886548 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:var_lib_t:s0 tclass=file permissive=0

type=SYSCALL msg=audit(1591617219.884:710): arch=x86_64 syscall=execve success=no exit=EACCES a0=55d3cbc52650 a1=55d3cbc69760 a2=55d3cbca6460 a3=55d3cb9fa010 items=0 ppid=1 pid=29203 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=(_service) exe=/usr/lib/systemd/systemd subj=system_u:system_r:init_t:s0 key=(null)

Hash: (_service),init_t,var_lib_t,file,execute_no_trans
```

Running `setenforce 0` and then `systemctl start akvvm_service.service` results in a working service which can retrieve certificates.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by inspecting /etc/systemd/system/akvvm_service.service and the executable under /var/lib/waagent/Microsoft.Azure.KeyVault.KeyVaultForLinux-1.0.1172.13/, then reproduce the failure with SELinux enforcing and review the reported audit denial. Done means akvvm_service.service starts and retrieves certificates without disabling SELinux.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
operating-systems, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.