flathub / com.discordapp.Discord

https://flathub.org/apps/details/com.discordapp.Discord
124 stars 42 forks source link

[0.0.49] Initial Discord load triggers SELinux #390

Open Gamertech opened 4 months ago

Gamertech commented 4 months ago

After updating the flatpak yesterday, Discord now triggers execheap on the first load and fails to start.

Previous recent updates it crashed on first load then works fine after that till next update, so possibly it crashed in a different way to usual and SELinux doesn't like it?



*****  Plugin allow_execheap (53.1 confidence) suggests   ********************

If you do not think Discord should need to map heap memory that is both writable and executable.
Then you need to report a bug. This is a potentially dangerous access.
Do
contact your security administrator and report this issue.

*****  Plugin catchall_boolean (42.6 confidence) suggests   ******************

If you want to allow selinuxuser to execheap
Then you must tell SELinux about this by enabling the 'selinuxuser_execheap' boolean.

Do
setsebool -P selinuxuser_execheap 1

*****  Plugin catchall (5.76 confidence) suggests   **************************

If you believe that Discord should be allowed execheap access on processes labeled unconfined_t 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 'Discord' --raw | audit2allow -M my-Discord
# semodule -X 300 -i my-Discord.pp

Additional Information:
Source Context                unconfined_u:unconfined_r:unconfined_t:s0-
                              s0:c0.c1023
Target Context                unconfined_u:unconfined_r:unconfined_t:s0-
                              s0:c0.c1023
Target Objects                Unknown [ process ]
Source                        Discord
Source Path                   Discord
Port                          <Unknown>
Host                          radium
Source RPM Packages           
Target RPM Packages           
SELinux Policy RPM            selinux-policy-targeted-39.5-1.fc39.noarch
Local Policy RPM              selinux-policy-targeted-39.5-1.fc39.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     radium
Platform                      Linux radium 6.8.5-201.fc39.x86_64 #1 SMP
                              PREEMPT_DYNAMIC Thu Apr 11 18:25:26 UTC 2024
                              x86_64
Alert Count                   123
First Seen                    2024-04-13 09:12:08 AEST
Last Seen                     2024-04-13 09:12:08 AEST
Local ID                      09c86eb2-d6bc-4a84-a1c8-96cbbe07393a

Raw Audit Messages
type=AVC msg=audit(1712963528.728:319): avc:  denied  { execheap } for  pid=4208 comm="Discord" scontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=process permissive=0

Hash: Discord,unconfined_t,unconfined_t,process,execheap```
timuzhti commented 2 months ago

This appears to be because some discord blobs have the executable stack flag set, which they do not appear to require. On 0.0.57, it also causes discord_voice.node to trigger the "Well, it looks like your Discord installation is corrupt." banner.

The flag can be unset using execstack(8), by first querying every ELF in ~/.var/app/com.discordapp.Discord/ with execstack -q, and then running execstack -c on every discord_<module>.node file that reports the flag as being set (X marker). Of course, discord should probably just fix their blobs so that they don't have the flag in the first place.