Bug 1767606

Summary: Cockpit cannot log in with google-authenticator when enabled.
Product: [Fedora] Fedora Reporter: Gwyn Ciesla <gwync>
Component: selinux-policyAssignee: Patrik Koncity <pkoncity>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: high    
Version: 31CC: aimery, bartmichu, dperpeet, dwalsh, dylan.graham, ichavero, lvrabec, mgrepl, plautrba, stefw, zpytela
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-24 20:14:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gwyn Ciesla 2019-10-31 19:11:36 UTC
SELinux is preventing cockpit-session from create access on the file .google_authenticator~Dg1YSq.

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

If you believe that cockpit-session should be allowed create access on the .google_authenticator~Dg1YSq 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 'cockpit-session' --raw | audit2allow -M my-cockpitsession
# semodule -X 300 -i my-cockpitsession.pp


Additional Information:
Source Context                system_u:system_r:cockpit_session_t:s0
Target Context                system_u:object_r:user_home_dir_t:s0
Target Objects                .google_authenticator~Dg1YSq [ file ]
Source                        cockpit-session
Source Path                   cockpit-session
Port                          <Unknown>
Host                          bamboo
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.14.4-39.fc31.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     bamboo
Platform                      Linux bamboo 5.3.7-301.fc31.x86_64 #1 SMP Mon Oct
                              21 19:18:58 UTC 2019 x86_64 x86_64
Alert Count                   2
First Seen                    2019-10-31 13:59:33 CDT
Last Seen                     2019-10-31 14:08:14 CDT
Local ID                      f939b7d9-da40-4d65-9ef1-662662711c0f

Raw Audit Messages
type=AVC msg=audit(1572548894.119:959): avc:  denied  { create } for  pid=15317 comm="cockpit-session" name=".google_authenticator~Dg1YSq" scontext=system_u:system_r:cockpit_session_t:s0 tcontext=system_u:object_r:user_home_dir_t:s0 tclass=file permissive=0


Hash: cockpit-session,cockpit_session_t,user_home_dir_t,file,create

Comment 1 Lukas Vrabec 2019-11-01 17:10:58 UTC
Hi Cockpit maintainers, 

Could you please put SELinux to permissive and test this feature and collect all SELinux denials? Then we could fix it in SELinux policy, but I would like to get approval what should be added to cockpit policy first. 

Thanks,
Lukas.

Comment 2 Martin Pitt 2019-11-05 13:40:19 UTC
@Gwyn, are you in a position to do that?  If not, can you please describe how you set up your system, so that we can replicate? I. e. this certainly requires changes to the PAM config and such. Thanks!

Comment 3 Gwyn Ciesla 2019-11-05 14:10:01 UTC
I can, just let me know specifically the commands you want me to use.  The only change other than package installation is this in /etc/pam.d/cockpit:
auth       required     pam_google_authenticator.so

Comment 4 Lukas Vrabec 2019-11-05 17:00:44 UTC
Martin, 

If you can reproduce it and give me list of SELinux denials, I can add these rules as SELinux boolean to the distribution policy. 

Thanks,
Lukas.

Comment 5 Martin Pitt 2019-11-11 14:09:07 UTC
@Lukas: Sorry for the delay! Here we are. I set up google-authenticator with Cockpit on current Fedora 31 (selinux-policy-3.14.4-39.fc31.noarch). After "setenforce 0", 2FA works (yay!), and I get these four violations:


AVC avc:  denied  { create } for  pid=8358 comm="cockpit-session" name=".google_authenticator~CeLwZc" scontext=system_u:system_r:cockpit_session_t:s0 tcontext=system_u:object_r:user_home_dir_t:s0 tclass=file permissive=1
AVC avc:  denied  { read write open } for  pid=8358 comm="cockpit-session" path="/home/admin/.google_authenticator~CeLwZc" dev="dm-0" ino=395796 scontext=system_u:system_r:cockpit_session_t:s0 tcontext=system_u:object_r:user_home_dir_t:s0 tclass=file permissive=1
AVC avc:  denied  { setattr } for  pid=8358 comm="cockpit-session" name=".google_authenticator~CeLwZc" dev="dm-0" ino=395796 scontext=system_u:system_r:cockpit_session_t:s0 tcontext=system_u:object_r:user_home_dir_t:s0 tclass=file permissive=1
AVC avc:  denied  { rename } for  pid=8358 comm="cockpit-session" name=".google_authenticator~CeLwZc" dev="dm-0" ino=395796 scontext=system_u:system_r:cockpit_session_t:s0 tcontext=system_u:object_r:user_home_dir_t:s0 tclass=file permissive=1

Allowing these sounds perfectly sensible to me -- This is just doing "by the book" updating of a file, and by design 2FA needs to update the file to update its time stamps and such.

As these changes need to be done in selinux-policy, I'm reassigning if you don't mind?

Comment 6 Lukas Vrabec 2019-11-11 14:23:02 UTC
Hi Martin, 

Ok this should be fixed on our side. Martin, would it be possible to provide some VM for testing purposes? 

@Patrik, 
We need SELinux boolean for cockpit to allow access user homedirs ( allow google-authenticator for cockpit), which will be turned off by default. 

THanks,
Lukas.

Comment 7 Lukas Vrabec 2019-11-12 09:36:30 UTC
*** Bug 1771041 has been marked as a duplicate of this bug. ***

Comment 8 Lukas Vrabec 2019-11-12 09:37:26 UTC
@Patrik, 
We need to make it more generic and allow it also for sshd domain via boolean.

Comment 9 Aimery de Malet Roquefort 2019-11-24 21:03:49 UTC
Do we have any updates on when this bug is likely to be closed?

Comment 10 Lukas Vrabec 2019-11-25 10:08:31 UTC
Hi Aimery de Malet Roquefort, 

Patrik is working on the fix:
https://github.com/fedora-selinux/selinux-policy/pull/293

Thanks,
Lukas.

Comment 11 Aimery de Malet Roquefort 2020-02-04 09:37:36 UTC
Any further updates on when this will be pulled into the main active branch of Fedora? Seems we have been waiting for this relatively simple fix forever.

Comment 12 Patrik Koncity 2020-02-04 10:17:41 UTC
Hi Aimery,

fix is still in progress.

Thanks, 
Patrik.

Comment 13 Michał 2020-08-25 20:18:12 UTC
Hello.

Any progress on that fix? Or at least a workaround?

Thanks, Michał

Comment 14 Patrik Koncity 2020-09-23 15:29:38 UTC
Hi Michal, 
we almost finished this fix, but this fix not depend only on selinux component.
So it also depend on agreement with maintainers of google authenticator.

Comment 15 Ben Cotton 2020-11-03 17:20:15 UTC
This message is a reminder that Fedora 31 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '31'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 31 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 16 Ben Cotton 2020-11-24 20:14:38 UTC
Fedora 31 changed to end-of-life (EOL) status on 2020-11-24. Fedora 31 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.