All of lore.kernel.org
 help / color / mirror / Atom feed
* PAM Security related issue
@ 2017-12-13  4:47 Aman Sharma
  2017-12-13  9:14 ` Aman Sharma
  2017-12-13 15:24 ` Stephen Smalley
  0 siblings, 2 replies; 9+ messages in thread
From: Aman Sharma @ 2017-12-13  4:47 UTC (permalink / raw)
  To: SELinux, Stephen Smalley, centos

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

Hi All,

just wanted to know the meaning of line *session    required
 pam_selinux.so open env_params *added in */etc/pam.d/sshd *file. Actually
I am facing one issue related to this. When I changed this *env_params to
restore *then my Sftp is not working.

Can anybody Please guide me on this.


-- 

Thanks
Aman
Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com

[-- Attachment #2: Type: text/html, Size: 681 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PAM Security related issue
  2017-12-13  4:47 PAM Security related issue Aman Sharma
@ 2017-12-13  9:14 ` Aman Sharma
  2017-12-13 15:24 ` Stephen Smalley
  1 sibling, 0 replies; 9+ messages in thread
From: Aman Sharma @ 2017-12-13  9:14 UTC (permalink / raw)
  To: SELinux, Stephen Smalley, centos

[-- Attachment #1: Type: text/plain, Size: 833 bytes --]

Also in the logs, I am getting the below error message :


Dec 13 13:00:00 aman authpriv 3 sshd: pam_selinux(sshd:session): Unable to
get valid context for sftpuser
Dec 13 13:00:00 aman authpriv 6 sshd: pam_unix(sshd:session): session
opened for user sftpuser by (uid=0)

On Wed, Dec 13, 2017 at 10:17 AM, Aman Sharma <amansh.sharma5@gmail.com>
wrote:

> Hi All,
>
> just wanted to know the meaning of line *session    required
>  pam_selinux.so open env_params *added in */etc/pam.d/sshd *file.
> Actually I am facing one issue related to this. When I changed this *env_params
> to restore *then my Sftp is not working.
>
> Can anybody Please guide me on this.
>
>
> --
>
> Thanks
> Aman
> Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com
>



-- 

Thanks
Aman
Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com

[-- Attachment #2: Type: text/html, Size: 1780 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PAM Security related issue
  2017-12-13  4:47 PAM Security related issue Aman Sharma
  2017-12-13  9:14 ` Aman Sharma
@ 2017-12-13 15:24 ` Stephen Smalley
  2017-12-13 16:10   ` Aman Sharma
  1 sibling, 1 reply; 9+ messages in thread
From: Stephen Smalley @ 2017-12-13 15:24 UTC (permalink / raw)
  To: Aman Sharma, SELinux, centos

On Tue, 2017-12-12 at 23:47 -0500, Aman Sharma wrote:
> Hi All,
> 
> just wanted to know the meaning of line session    required   
>  pam_selinux.so open env_params added in /etc/pam.d/sshd file.
> Actually I am facing one issue related to this. When I changed this
> env_params to restore then my Sftp is not working. 
> 
> Can anybody Please guide me on this.

man pam_selinux describes the options and what they mean.
Why did you change it to restore?  Per the man page, restore is to
temporarily restore the contexts and would be a separate entry in the
PAM stack before the module that needs the original contexts, followed
by a pam_selinux.so open env_params after that module to set them up
again.  But don't use restore unless you actually need it for some
reason.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PAM Security related issue
  2017-12-13 15:24 ` Stephen Smalley
@ 2017-12-13 16:10   ` Aman Sharma
  2017-12-13 18:17     ` Dominick Grift
  2017-12-13 19:15     ` Stephen Smalley
  0 siblings, 2 replies; 9+ messages in thread
From: Aman Sharma @ 2017-12-13 16:10 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: SELinux, centos

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

Hi Stephen,

Yes , I am using open env_params for it. But for this, my sftp is not
working and getting the below error message :

Dec 13 13:00:00 aman authpriv 3 sshd: pam_selinux(sshd:session): Unable to
get valid context for sftpuser
Dec 13 13:00:00 aman authpriv 6 sshd: pam_unix(sshd:session): session
opened for user sftpuser by (uid=0)

Please let me know if you have any idea on this.

On Wed, Dec 13, 2017 at 8:54 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:

> On Tue, 2017-12-12 at 23:47 -0500, Aman Sharma wrote:
> > Hi All,
> >
> > just wanted to know the meaning of line session    required
> >  pam_selinux.so open env_params added in /etc/pam.d/sshd file.
> > Actually I am facing one issue related to this. When I changed this
> > env_params to restore then my Sftp is not working.
> >
> > Can anybody Please guide me on this.
>
> man pam_selinux describes the options and what they mean.
> Why did you change it to restore?  Per the man page, restore is to
> temporarily restore the contexts and would be a separate entry in the
> PAM stack before the module that needs the original contexts, followed
> by a pam_selinux.so open env_params after that module to set them up
> again.  But don't use restore unless you actually need it for some
> reason.
>
>
>
>


-- 

Thanks
Aman
Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com

[-- Attachment #2: Type: text/html, Size: 2198 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PAM Security related issue
  2017-12-13 16:10   ` Aman Sharma
@ 2017-12-13 18:17     ` Dominick Grift
  2017-12-13 19:15     ` Stephen Smalley
  1 sibling, 0 replies; 9+ messages in thread
From: Dominick Grift @ 2017-12-13 18:17 UTC (permalink / raw)
  To: selinux

[-- Attachment #1: Type: text/plain, Size: 1918 bytes --]

On Wed, Dec 13, 2017 at 09:40:25PM +0530, Aman Sharma wrote:
> Hi Stephen,
> 
> Yes , I am using open env_params for it. But for this, my sftp is not
> working and getting the below error message :
> 
> Dec 13 13:00:00 aman authpriv 3 sshd: pam_selinux(sshd:session): Unable to
> get valid context for sftpuser
> Dec 13 13:00:00 aman authpriv 6 sshd: pam_unix(sshd:session): session
> opened for user sftpuser by (uid=0)

Not sure if this is actually the issue but:

AFAIK the user must have access to "context contains" for env_params

See if the context assoc. with the sftpuser process has access to context contains

> 
> Please let me know if you have any idea on this.
> 
> On Wed, Dec 13, 2017 at 8:54 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> 
> > On Tue, 2017-12-12 at 23:47 -0500, Aman Sharma wrote:
> > > Hi All,
> > >
> > > just wanted to know the meaning of line session    required
> > >  pam_selinux.so open env_params added in /etc/pam.d/sshd file.
> > > Actually I am facing one issue related to this. When I changed this
> > > env_params to restore then my Sftp is not working.
> > >
> > > Can anybody Please guide me on this.
> >
> > man pam_selinux describes the options and what they mean.
> > Why did you change it to restore?  Per the man page, restore is to
> > temporarily restore the contexts and would be a separate entry in the
> > PAM stack before the module that needs the original contexts, followed
> > by a pam_selinux.so open env_params after that module to set them up
> > again.  But don't use restore unless you actually need it for some
> > reason.
> >
> >
> >
> >
> 
> 
> -- 
> 
> Thanks
> Aman
> Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com

-- 
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PAM Security related issue
  2017-12-13 16:10   ` Aman Sharma
  2017-12-13 18:17     ` Dominick Grift
@ 2017-12-13 19:15     ` Stephen Smalley
  2017-12-14  7:18       ` Aman Sharma
  1 sibling, 1 reply; 9+ messages in thread
From: Stephen Smalley @ 2017-12-13 19:15 UTC (permalink / raw)
  To: Aman Sharma; +Cc: SELinux

On Wed, 2017-12-13 at 21:40 +0530, Aman Sharma wrote:
> Hi Stephen,
> 
> Yes , I am using open env_params for it. But for this, my sftp is not
> working and getting the below error message :
> 
> Dec 13 13:00:00 aman authpriv 3 sshd: pam_selinux(sshd:session):
> Unable to get valid context for sftpuser
> Dec 13 13:00:00 aman authpriv 6 sshd: pam_unix(sshd:session): session
> opened for user sftpuser by (uid=0)
> 
> Please let me know if you have any idea on this.

Do you have any semanage login mapping for sftpuser or is it just using
the __default__ entry? (what does semanage login -l show)  How was
sftpuser created?

You could add the debug option on the pam_selinux.so line to try to get
more information.

You could run selinuxdefcon to query what context would be used for
that user, e.g.
selinuxdefcon sftpuser system_u:system_r:sshd_t:s0-s0.c0123

> 
> On Wed, Dec 13, 2017 at 8:54 PM, Stephen Smalley <sds@tycho.nsa.gov>
> wrote:
> > On Tue, 2017-12-12 at 23:47 -0500, Aman Sharma wrote:
> > > Hi All,
> > >
> > > just wanted to know the meaning of line session    required   
> > >  pam_selinux.so open env_params added in /etc/pam.d/sshd file.
> > > Actually I am facing one issue related to this. When I changed
> > this
> > > env_params to restore then my Sftp is not working. 
> > >
> > > Can anybody Please guide me on this.
> > 
> > man pam_selinux describes the options and what they mean.
> > Why did you change it to restore?  Per the man page, restore is to
> > temporarily restore the contexts and would be a separate entry in
> > the
> > PAM stack before the module that needs the original contexts,
> > followed
> > by a pam_selinux.so open env_params after that module to set them
> > up
> > again.  But don't use restore unless you actually need it for some
> > reason.
> > 
> > 
> > 
> > 
> 
> 
> 
> -- 
> 
> Thanks
> Aman
> Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PAM Security related issue
  2017-12-13 19:15     ` Stephen Smalley
@ 2017-12-14  7:18       ` Aman Sharma
  2017-12-14  8:16         ` Dominick Grift
  2017-12-14 13:49         ` Stephen Smalley
  0 siblings, 2 replies; 9+ messages in thread
From: Aman Sharma @ 2017-12-14  7:18 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: SELinux

[-- Attachment #1: Type: text/plain, Size: 3206 bytes --]

Hi All,

Below is the output of semanage USer command output for sftpuser:

*specialuser_u   user       s0         s0
 sysadm_r system_r*

and for command semanage login -l , output is :

*sftpuser             specialuser_u        s0                   **

*and also, after adding the debugging option, its showing the below error
message as :*

Dec 13 15:46:10 cucmSUB authpriv 3 sshd: pam_selinux(sshd:session): Unable
to get valid context for sftpuser

Dec 13 15:46:10 cucmSUB authpriv 5 sshd: pam_selinux(sshd:session): Open
Session

Dec 13 15:46:11 cucmSUB authpriv 7 sshd: pam_selinux(sshd:session):
Username= sftpuser SELinux User= specialuser_u Level= s0

Dec 13 15:46:11 cucmSUB authpriv 3 sshd: pam_selinux(sshd:session): Unable
to get valid context for sftpuser


also Selinuxdefcon command is showing error while running for sftpuser i.e.

*sudo /usr/sbin/selinuxdefcon sftpuser system_u:system_r:sshd_t:s0*

*/usr/sbin/selinuxdefcon: Invalid argument*


*Please let me know your comments on this.*


*Thanks*

*Aman*

On Thu, Dec 14, 2017 at 12:45 AM, Stephen Smalley <sds@tycho.nsa.gov> wrote:

> On Wed, 2017-12-13 at 21:40 +0530, Aman Sharma wrote:
> > Hi Stephen,
> >
> > Yes , I am using open env_params for it. But for this, my sftp is not
> > working and getting the below error message :
> >
> > Dec 13 13:00:00 aman authpriv 3 sshd: pam_selinux(sshd:session):
> > Unable to get valid context for sftpuser
> > Dec 13 13:00:00 aman authpriv 6 sshd: pam_unix(sshd:session): session
> > opened for user sftpuser by (uid=0)
> >
> > Please let me know if you have any idea on this.
>
> Do you have any semanage login mapping for sftpuser or is it just using
> the __default__ entry? (what does semanage login -l show)  How was
> sftpuser created?
>
> You could add the debug option on the pam_selinux.so line to try to get
> more information.
>
> You could run selinuxdefcon to query what context would be used for
> that user, e.g.
> selinuxdefcon sftpuser system_u:system_r:sshd_t:s0-s0.c0123
>
> >
> > On Wed, Dec 13, 2017 at 8:54 PM, Stephen Smalley <sds@tycho.nsa.gov>
> > wrote:
> > > On Tue, 2017-12-12 at 23:47 -0500, Aman Sharma wrote:
> > > > Hi All,
> > > >
> > > > just wanted to know the meaning of line session    required
> > > >  pam_selinux.so open env_params added in /etc/pam.d/sshd file.
> > > > Actually I am facing one issue related to this. When I changed
> > > this
> > > > env_params to restore then my Sftp is not working.
> > > >
> > > > Can anybody Please guide me on this.
> > >
> > > man pam_selinux describes the options and what they mean.
> > > Why did you change it to restore?  Per the man page, restore is to
> > > temporarily restore the contexts and would be a separate entry in
> > > the
> > > PAM stack before the module that needs the original contexts,
> > > followed
> > > by a pam_selinux.so open env_params after that module to set them
> > > up
> > > again.  But don't use restore unless you actually need it for some
> > > reason.
> > >
> > >
> > >
> > >
> >
> >
> >
> > --
> >
> > Thanks
> > Aman
> > Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com
>



-- 

Thanks
Aman
Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com

[-- Attachment #2: Type: text/html, Size: 7302 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PAM Security related issue
  2017-12-14  7:18       ` Aman Sharma
@ 2017-12-14  8:16         ` Dominick Grift
  2017-12-14 13:49         ` Stephen Smalley
  1 sibling, 0 replies; 9+ messages in thread
From: Dominick Grift @ 2017-12-14  8:16 UTC (permalink / raw)
  To: selinux

[-- Attachment #1: Type: text/plain, Size: 3983 bytes --]

1. cat /etc/selinux/targeted/contexts/users/specialuser_u
2. priv logins are allowed as per the ssh_priv_logins boolean?
3. do you get the same result when you associate "sftpuser" with selinux user "user_u"?

On Thu, Dec 14, 2017 at 12:48:42PM +0530, Aman Sharma wrote:
> Hi All,
> 
> Below is the output of semanage USer command output for sftpuser:
> 
> *specialuser_u   user       s0         s0
>  sysadm_r system_r*
> 
> and for command semanage login -l , output is :
> 
> *sftpuser             specialuser_u        s0                   **
> 
> *and also, after adding the debugging option, its showing the below error
> message as :*
> 
> Dec 13 15:46:10 cucmSUB authpriv 3 sshd: pam_selinux(sshd:session): Unable
> to get valid context for sftpuser
> 
> Dec 13 15:46:10 cucmSUB authpriv 5 sshd: pam_selinux(sshd:session): Open
> Session
> 
> Dec 13 15:46:11 cucmSUB authpriv 7 sshd: pam_selinux(sshd:session):
> Username= sftpuser SELinux User= specialuser_u Level= s0
> 
> Dec 13 15:46:11 cucmSUB authpriv 3 sshd: pam_selinux(sshd:session): Unable
> to get valid context for sftpuser
> 
> 
> also Selinuxdefcon command is showing error while running for sftpuser i.e.
> 
> *sudo /usr/sbin/selinuxdefcon sftpuser system_u:system_r:sshd_t:s0*
> 
> */usr/sbin/selinuxdefcon: Invalid argument*
> 
> 
> *Please let me know your comments on this.*
> 
> 
> *Thanks*
> 
> *Aman*
> 
> On Thu, Dec 14, 2017 at 12:45 AM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> 
> > On Wed, 2017-12-13 at 21:40 +0530, Aman Sharma wrote:
> > > Hi Stephen,
> > >
> > > Yes , I am using open env_params for it. But for this, my sftp is not
> > > working and getting the below error message :
> > >
> > > Dec 13 13:00:00 aman authpriv 3 sshd: pam_selinux(sshd:session):
> > > Unable to get valid context for sftpuser
> > > Dec 13 13:00:00 aman authpriv 6 sshd: pam_unix(sshd:session): session
> > > opened for user sftpuser by (uid=0)
> > >
> > > Please let me know if you have any idea on this.
> >
> > Do you have any semanage login mapping for sftpuser or is it just using
> > the __default__ entry? (what does semanage login -l show)  How was
> > sftpuser created?
> >
> > You could add the debug option on the pam_selinux.so line to try to get
> > more information.
> >
> > You could run selinuxdefcon to query what context would be used for
> > that user, e.g.
> > selinuxdefcon sftpuser system_u:system_r:sshd_t:s0-s0.c0123
> >
> > >
> > > On Wed, Dec 13, 2017 at 8:54 PM, Stephen Smalley <sds@tycho.nsa.gov>
> > > wrote:
> > > > On Tue, 2017-12-12 at 23:47 -0500, Aman Sharma wrote:
> > > > > Hi All,
> > > > >
> > > > > just wanted to know the meaning of line session    required
> > > > >  pam_selinux.so open env_params added in /etc/pam.d/sshd file.
> > > > > Actually I am facing one issue related to this. When I changed
> > > > this
> > > > > env_params to restore then my Sftp is not working.
> > > > >
> > > > > Can anybody Please guide me on this.
> > > >
> > > > man pam_selinux describes the options and what they mean.
> > > > Why did you change it to restore?  Per the man page, restore is to
> > > > temporarily restore the contexts and would be a separate entry in
> > > > the
> > > > PAM stack before the module that needs the original contexts,
> > > > followed
> > > > by a pam_selinux.so open env_params after that module to set them
> > > > up
> > > > again.  But don't use restore unless you actually need it for some
> > > > reason.
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > >
> > > Thanks
> > > Aman
> > > Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com
> >
> 
> 
> 
> -- 
> 
> Thanks
> Aman
> Cell: +91 9990296404 |  Email ID : amansh.sharma5@gmail.com

-- 
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: PAM Security related issue
  2017-12-14  7:18       ` Aman Sharma
  2017-12-14  8:16         ` Dominick Grift
@ 2017-12-14 13:49         ` Stephen Smalley
  1 sibling, 0 replies; 9+ messages in thread
From: Stephen Smalley @ 2017-12-14 13:49 UTC (permalink / raw)
  To: Aman Sharma; +Cc: SELinux

On Thu, 2017-12-14 at 12:48 +0530, Aman Sharma wrote:
> Hi All,
> 
> Below is the output of semanage USer command output for sftpuser:
> 
> specialuser_u   user       s0         s0                           
>  sysadm_r system_r
> 
> and for command semanage login -l , output is :
> 
> sftpuser             specialuser_u        s0                   *
> 
> and also, after adding the debugging option, its showing the below
> error message as 
> 
> Dec 13 15:46:10 cucmSUB authpriv 3 sshd: pam_selinux(sshd:session):
> Unable to get valid context for sftpuser
> Dec 13 15:46:10 cucmSUB authpriv 5 sshd: pam_selinux(sshd:session):
> Open Session
> Dec 13 15:46:11 cucmSUB authpriv 7 sshd: pam_selinux(sshd:session):
> Username= sftpuser SELinux User= specialuser_u Level= s0
> Dec 13 15:46:11 cucmSUB authpriv 3 sshd: pam_selinux(sshd:session):
> Unable to get valid context for sftpuser
> 
> also Selinuxdefcon command is showing error while running for
> sftpuser i.e. 
> sudo /usr/sbin/selinuxdefcon sftpuser system_u:system_r:sshd_t:s0
> /usr/sbin/selinuxdefcon: Invalid argument
> 
> Please let me know your comments on this.

Is there a reason why you've added your own unique SELinux user and
login entries for sftpuser rather than either just mapping to one of
the existing users if you want it to be confined or leaving it
unspecified and just using the __default__ entry if you want it to be
unconfined?

The entries above say that sftpuser is to be mapped to specialuser_u,
and that specialuser_u can only use the sysadm_r or system_r roles.  To
make that work, you would also need to enable the ssh_sysadm_login
boolean and cp /etc/selinux/targeted/contexts/users/sysadm_u
/etc/selinux/targeted/contexts/users/specialuser_u.  But that seems
pointless since you could just leave it unmapped or map it to sysadm_u
in the first place if that was really what you wanted.

If you want sftpuser to be unrestricted, just remove the mappings, i.e.
$ sudo semanage login -d sftpuser
$ sudo semanage user -d specialuser_u
$ selinuxdefcon sftpuser system_u:system_r:sshd_t:s0-s0:c0.c1023
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-12-14 13:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13  4:47 PAM Security related issue Aman Sharma
2017-12-13  9:14 ` Aman Sharma
2017-12-13 15:24 ` Stephen Smalley
2017-12-13 16:10   ` Aman Sharma
2017-12-13 18:17     ` Dominick Grift
2017-12-13 19:15     ` Stephen Smalley
2017-12-14  7:18       ` Aman Sharma
2017-12-14  8:16         ` Dominick Grift
2017-12-14 13:49         ` Stephen Smalley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.