Skip to contentSkip to conversation

PATH records show fcaps

PATCH Eric Paris 3 participants 16 messages Oct 18, 2008 – Oct 21, 2008

Subsystems (3)
lore
Share & tools
lore

Eric Paris

author maintainer
#0 lore raw

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) type=EXECVE msg=audit(1224342849.465:43): argc=2 a0="ping" a1="127.0.0.1"
type=CWD msg=audit(1224342849.465:43): cwd="/root"
type=PATH msg=audit(1224342849.465:43): item=0 name="/bin/ping" inode=49227 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_permitted=0000000000002000 cap_inheritable=0000000000000000
type=PATH msg=audit(1224342849.465:43): item=1 name=(null) inode=507963 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ld_so_t:s0

This good? If either cap_permitted or cap_inheritable have anything set I show them both. In the above example would you rather I only showed cap_permitted and dropped cap_inheritable? Did I see correctly that it's possible to set a cap_effective on a file? Does it do anything? I didn't see that getting used or read in the kernel, so I didn't put any way to display it in kernel....

-Eric

---

 include/linux/capability.h |   11 ++++
 kernel/auditsc.c           |   68 ++++++++++++++++++++++++--
 security/commoncap.c       |  115 +++++++++++++++++++++++++-------------------
 3 files changed, 140 insertions(+), 54 deletions(-)
include/linux/capability.h +11 -0
index 9d1fe30..a3785e7 100644
@@ -96,6 +96,13 @@ typedef struct kernel_cap_struct {
 	__u32 cap[_KERNEL_CAPABILITY_U32S];
 } kernel_cap_t;
 
+/* exact same as vfs_cap_data but in cpu endian and always filled completely */
+struct cpu_vfs_cap_data {
+	__u32 magic_etc;
+	kernel_cap_t permitted;
+	kernel_cap_t inheritable;
+};
+
 #define _USER_CAP_HEADER_SIZE  (sizeof(struct __user_cap_header_struct))
 #define _KERNEL_CAP_T_SIZE     (sizeof(kernel_cap_t))
 
@@ -517,6 +524,10 @@ kernel_cap_t cap_set_effective(const kernel_cap_t pE_new);
 
 extern int capable(int cap);
 
+/* audit system wants to get cap info from files as well */
+struct dentry;
+extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
+
 #endif /* __KERNEL__ */
 
 #endif /* !_LINUX_CAPABILITY_H */
kernel/auditsc.c +63 -5

129 lines not on this page · raw message

security/commoncap.c +66 -49

153 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · On Saturday 18 October 2008 11:23:12 Eric Paris wrote:

type=PATH msg=audit(1224342849.465:43): item=0 name="/bin/ping" inode=49227 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_permitted=0000000000002000 cap_inheritable=0000000000000000

The kernel abbreviates these as: capprm & capinh in the proc file system. I'm thinking shorter names would save some disk space.

Quoted 2 lines

This good? If either cap_permitted or cap_inheritable have anything set I show them both.

And they are otherwise missing to save disk space?

Quoted 2 lines

In the above example would you rather I only showed cap_permitted and dropped cap_inheritable?

No. Its my understanding that apps could have something inheritable by children and we'd want to know exactly what that was.

Quoted 1 line

Did I see correctly that it's possible to set a cap_effective on a file?

Yes.

Quoted 2 lines

Does it do anything? I didn't see that getting used or read in the kernel, so I didn't put any way to display it in kernel....

That would be strange to have a field that is not used.

I'll leave code review to others. Thanks for working on this patch!

-Steve

author maintainer
#2 lore raw
Quoted 6 lines · Steve Grubb
Quoted 4 lines · On Saturday 18 October 2008 11:23:12 Eric Paris wrote:

type=PATH msg=audit(1224342849.465:43): item=0 name="/bin/ping" inode=49227 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_permitted=0000000000002000 cap_inheritable=0000000000000000

Quoted 7 lines

The kernel abbreviates these as: capprm & capinh in the proc file system. I'm thinking shorter names would save some disk space.

Quoted 2 lines

This good? If either cap_permitted or cap_inheritable have anything set I show them both.

And they are otherwise missing to save disk space?

Yes, see the example :)

Quoted 5 lines
Quoted 2 lines

In the above example would you rather I only showed cap_permitted and dropped cap_inheritable?

No. Its my understanding that apps could have something inheritable by children and we'd want to know exactly what that was.

Notice this record is only about the perms on the file. My question was that in the above example I have a capprm set on the file but I do not have a capinh set on the file. To save space would you rather I only showed the capprm or should I show the 0 capinh as well? The opposite would also be true, if I had capinh set on a file but didn't have capprm set should I display only the capinh or display both capinh and a blank capprm?

#3 lore raw
In reply to Eric Paris
Quoted 9 lines · Eric Paris

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) type=EXECVE msg=audit(1224342849.465:43): argc=2 a0="ping" a1="127.0.0.1"
type=CWD msg=audit(1224342849.465:43): cwd="/root"
type=PATH msg=audit(1224342849.465:43): item=0 name="/bin/ping" inode=49227 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_permitted=0000000000002000 cap_inheritable=0000000000000000
type=PATH msg=audit(1224342849.465:43): item=1 name=(null) inode=507963 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ld_so_t:s0

This good? If either cap_permitted or cap_inheritable have anything set I show them both. In the above example would you rather I only showed cap_permitted and dropped cap_inheritable? Did I see correctly that

I think dropping the empty one is fine.

Steve's suggestion of cap_prm and cap_inh are good for being shorter and matching proc output. But OTOH it's a bit confusing as at first I thought these were the task's values. Would it be too terse to just use fP and fI?

Quoted 3 lines

it's possible to set a cap_effective on a file? Does it do anything? I didn't see that getting used or read in the kernel, so I didn't put any way to display it in kernel....

<background>
The idea is that putting bits in fE will cause them to be in pE' after exec. But the way it is interpreted is as a boolean, so either pE' is empty or it is set to pP'. So if you do

setcap cap_dac_override=pe /bin/foo

then executing /bin/foo will land cap_dac_override in your effective and permitted sets. If you do

setcap cap_dac_override=pe /bin/foo

then it will land only in your permitted set.

</background>

<summary>

I thought the kernel looked at the actual contents of fE, but now I see that instead setcap sets a VFS_CAP_FLAGS_EFFECTIVE flag in the capability xattr magic value. So the effective value appears to be unused. But the VFS_CAP_FLAGS_EFFECTIVE (aka 'legacy bit'), if set, is obviously very important, and should be printed out, at least if it is set. Perhaps just 'cap_legacy=true' if it's set?

And actually the capability revision # might be useful too. Perhaps output that only if it doesn't match kernel default (VFS_CAP_REVISION)?

</summary>

-serge

#9 lore raw
In reply to Eric Paris
Quoted 1 line · Eric Paris

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)

This part above is the credentials of the running task, right? Will it output your process inheritable set if nonempty?

(I would think you should be able to test this by doing

	capsh --inh=cap_sys_admin /bin/sh
	/bin/foo

and look for /bin/foo's record)

thanks,
-serge

author maintainer
#4 lore raw
In reply to Serge E. Hallyn
Quoted 11 lines · Serge E. Hallyn
Quoted 9 lines · Eric Paris

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) type=EXECVE msg=audit(1224342849.465:43): argc=2 a0="ping" a1="127.0.0.1"
type=CWD msg=audit(1224342849.465:43): cwd="/root"
type=PATH msg=audit(1224342849.465:43): item=0 name="/bin/ping" inode=49227 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_permitted=0000000000002000 cap_inheritable=0000000000000000
type=PATH msg=audit(1224342849.465:43): item=1 name=(null) inode=507963 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ld_so_t:s0

This good? If either cap_permitted or cap_inheritable have anything set I show them both. In the above example would you rather I only showed cap_permitted and dropped cap_inheritable? Did I see correctly that

Quoted 6 lines

I think dropping the empty one is fine.

Steve's suggestion of cap_prm and cap_inh are good for being shorter and matching proc output. But OTOH it's a bit confusing as at first I thought these were the task's values. Would it be too terse to just use fP and fI?

yes, too terse. How about cap_fP, cap_fI, cap_fVer, cap_fEffBit ?

Based on your other comments I'm going to go add fVer and fEffBit.

#5 lore raw
Quoted 12 lines · Eric Paris
Quoted 11 lines · Serge E. Hallyn
Quoted 9 lines · Eric Paris

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) type=EXECVE msg=audit(1224342849.465:43): argc=2 a0="ping" a1="127.0.0.1"
type=CWD msg=audit(1224342849.465:43): cwd="/root"
type=PATH msg=audit(1224342849.465:43): item=0 name="/bin/ping" inode=49227 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_permitted=0000000000002000 cap_inheritable=0000000000000000
type=PATH msg=audit(1224342849.465:43): item=1 name=(null) inode=507963 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:ld_so_t:s0

This good? If either cap_permitted or cap_inheritable have anything set I show them both. In the above example would you rather I only showed cap_permitted and dropped cap_inheritable? Did I see correctly that

Quoted 8 lines
Quoted 6 lines

I think dropping the empty one is fine.

Steve's suggestion of cap_prm and cap_inh are good for being shorter and matching proc output. But OTOH it's a bit confusing as at first I thought these were the task's values. Would it be too terse to just use fP and fI?

yes, too terse. How about cap_fP, cap_fI, cap_fVer, cap_fEffBit ?

Well it's a PATH record type so it should be obvious that these are file caps, so better to stick with Steve's suggestions, right?

Quoted 1 line

Based on your other comments I'm going to go add fVer and fEffBit.

cap_ver and cap_legacy?

I can't explain it, but fEffBit makes me think of Twiki...

thanks,
-serge

author maintainer
#10 lore raw
In reply to Serge E. Hallyn
Quoted 8 lines · Serge E. Hallyn
Quoted 1 line · Eric Paris

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)

This part above is the credentials of the running task, right? Will it output your process inheritable set if nonempty?

(I would think you should be able to test this by doing

Quoted 7 lines
	capsh --inh=cap_sys_admin /bin/sh
	/bin/foo

and look for /bin/foo's record)

thanks,
-serge

For this (patch 2) I'm adding information so you can tell a process escalated it privs with fcaps. This really means you have to audit EXECVE (since this is when fcaps are applied)

setcap "cap_net_admin+pei" /bin/bash
setcap "cap_net_raw+pei" /bin/ping

auditctl -a exit,always -S execve -F path=/bin/ping

type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=1 name=(null) inode=507963 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ld_so_t:s0
type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=0 name=/bin/ping inode=49227 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_fP=0000000000002000 cap_fE=1 cap_fVer=2
type=CWD msg=audit(10/20/2008 13:27:55.318:218) : cwd=/home/test
type=UNKNOWN[1321] msg=audit(10/20/2008 13:27:55.318:218) : cap_fP=0000000000002000 cap_fI=0000000000000000 cap_fE=1 cap_pP=0000000000001000 cap_pI=0000000000000000 cap_pE=0000000000001000 cap_bprmE=0000000000002000
type=EXECVE msg=audit(10/20/2008 13:27:55.318:218) : argc=(null) a0=ping a1=127.0.0.1
type=SYSCALL msg=audit(10/20/2008 13:27:55.318:218) : arch=x86_64 syscall=execve success=yes exit=0 a0=2225590 a1=22257e0 a2=223ae30 a3=3445170a70 items=2 ppid=2994 pid=3023 auid=root uid=test gid=test euid=test suid=test fsuid=test egid=test sgid=test fsgid=test tty=pts0 ses=1 comm=ping exe=/bin/ping subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)

My initial shell shows in /proc/self/status (matches above)
CapInh: 0000000000000000
CapPrm: 0000000000001000
CapEff: 0000000000001000
CapBnd: ffffffffffffffff

So looking at this type=UNKNOWN line is the most interesting. I do a if(!issubset(cap_bprmEff, pP & pI). I probaly should add a if(fE && !issubset(cap_bprmEff, pE & pI)) as well. So, if we are going to change pP (and possibly pE) something like the above set of audit messages is going to pop out. In this case my login shell is ppid=2994 and the pid=3023 is the ping program executing. Ping worked just fine.

Take note that at this point in the code pE and pP still show cap_net_admin (from the /bin/bash fcap) but when ping actually finishes execve and runs it won't have that cap since it isn't in pI.

Patch #3 is going to display more information for sys_capset (assuming you turn on auditctl -a exit,always -S capset). I already wrote that patch but now I need to figure out a program that call sys_capset...

-Eric

#11 lore raw
Quoted 24 lines · Eric Paris
Quoted 8 lines · Serge E. Hallyn
Quoted 1 line · Eric Paris

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)

This part above is the credentials of the running task, right? Will it output your process inheritable set if nonempty?

(I would think you should be able to test this by doing

Quoted 7 lines
	capsh --inh=cap_sys_admin /bin/sh
	/bin/foo

and look for /bin/foo's record)

thanks,
-serge

For this (patch 2) I'm adding information so you can tell a process escalated it privs with fcaps. This really means you have to audit EXECVE (since this is when fcaps are applied)

setcap "cap_net_admin+pei" /bin/bash
setcap "cap_net_raw+pei" /bin/ping

Quoted 6 lines

auditctl -a exit,always -S execve -F path=/bin/ping

type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=1 name=(null) inode=507963 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ld_so_t:s0
type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=0 name=/bin/ping inode=49227 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_fP=0000000000002000 cap_fE=1 cap_fVer=2 type=CWD msg=audit(10/20/2008 13:27:55.318:218) : cwd=/home/test
type=UNKNOWN[1321] msg=audit(10/20/2008 13:27:55.318:218) : cap_fP=0000000000002000 cap_fI=0000000000000000 cap_fE=1 cap_pP=0000000000001000 cap_pI=0000000000000000 cap_pE=0000000000001000 cap_bprmE=0000000000002000

This looks wrong - you say above that you set cap_net_raw in fI for ping, but this shows fI as empty?

-serge

author maintainer
#12 lore raw
Quoted 27 lines · Serge E. Hallyn
Quoted 26 lines · Eric Paris
Quoted 8 lines · Serge E. Hallyn
Quoted 1 line · Eric Paris

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)

This part above is the credentials of the running task, right? Will it output your process inheritable set if nonempty?

(I would think you should be able to test this by doing

Quoted 7 lines
	capsh --inh=cap_sys_admin /bin/sh
	/bin/foo

and look for /bin/foo's record)

thanks,
-serge

For this (patch 2) I'm adding information so you can tell a process escalated it privs with fcaps. This really means you have to audit EXECVE (since this is when fcaps are applied)

setcap "cap_net_admin+pei" /bin/bash
setcap "cap_net_raw+pei" /bin/ping

auditctl -a exit,always -S execve -F path=/bin/ping

Quoted 7 lines
Quoted 4 lines

type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=1 name=(null) inode=507963 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ld_so_t:s0
type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=0 name=/bin/ping inode=49227 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_fP=0000000000002000 cap_fE=1 cap_fVer=2 type=CWD msg=audit(10/20/2008 13:27:55.318:218) : cwd=/home/test
type=UNKNOWN[1321] msg=audit(10/20/2008 13:27:55.318:218) : cap_fP=0000000000002000 cap_fI=0000000000000000 cap_fE=1 cap_pP=0000000000001000 cap_pI=0000000000000000 cap_pE=0000000000001000 cap_bprmE=0000000000002000

This looks wrong - you say above that you set cap_net_raw in fI for ping, but this shows fI as empty?

/*
* pP' = (X & fP) | (pI & fI)
*/

Not going to disagree that is weird but fcaps aren't inheritable from my looking at the code. Both fP and fI get collapsed by the above equation (X is the per process bounding set) into bprm->cap_post_exec_permitted. Then at the end of execve, cap_bprm_apply_creds(), you get:

bprm->cap_post_exec_permitted = cap_intersect(bprm->cap_post_exec_permitted,

                                              current->cap_permitted);
[snip]
current->cap_permitted = bprm->cap_post_exec_permitted;
if (bprm->cap_effective)
        current->cap_effective = bprm->cap_post_exec_permitted;

fcaps at least from my reading are not inheritable and basically it looks to me like the only thing fI really means is that they can get pushed into pP (and pE) if they intersect with pI.

/me doesn't really mind having fI not be inheritable. Although I'm not sure why we need that weird twist on the meaning fI....

-Eric

#13 lore raw
Quoted 33 lines · Eric Paris
Quoted 32 lines · Serge E. Hallyn
Quoted 30 lines · Eric Paris
Quoted 8 lines · Serge E. Hallyn
Quoted 1 line · Eric Paris

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)

This part above is the credentials of the running task, right? Will it output your process inheritable set if nonempty?

(I would think you should be able to test this by doing

Quoted 7 lines
	capsh --inh=cap_sys_admin /bin/sh
	/bin/foo

and look for /bin/foo's record)

thanks,
-serge

For this (patch 2) I'm adding information so you can tell a process escalated it privs with fcaps. This really means you have to audit EXECVE (since this is when fcaps are applied)

setcap "cap_net_admin+pei" /bin/bash
setcap "cap_net_raw+pei" /bin/ping

auditctl -a exit,always -S execve -F path=/bin/ping

type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=1 name=(null) inode=507963 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ld_so_t:s0
type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=0 name=/bin/ping inode=49227 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_fP=0000000000002000 cap_fE=1 cap_fVer=2 type=CWD msg=audit(10/20/2008 13:27:55.318:218) : cwd=/home/test
type=UNKNOWN[1321] msg=audit(10/20/2008 13:27:55.318:218) : cap_fP=0000000000002000 cap_fI=0000000000000000 cap_fE=1 cap_pP=0000000000001000 cap_pI=0000000000000000 cap_pE=0000000000001000 cap_bprmE=0000000000002000

Quoted 8 lines
Quoted 2 lines

This looks wrong - you say above that you set cap_net_raw in fI for ping, but this shows fI as empty?

/*
* pP' = (X & fP) | (pI & fI)
*/

Not going to disagree that is weird but fcaps aren't inheritable from my

I'm not saying I expected to see them in pP. I'm saying that you report cap_fI as empty. I assume cap_fI should be fI straight out of the xattr. Above you said you put cap_net_raw into fI.

So unless you had actually done 'setcap "cap_net_raw+pe" /bin/ping' before collecting that audit record, it looks like you've got a bug in grabbing fI.

(As for the way fI is used, you are exactliy right - it is masked against pI then placed in pP'. The idea is that your process can carry ambient privileges which are only enabled if the file lets you, but at the same time are not enabled for tasks which don't have it in pI. So the example I usually use is if you have a limited administrative role which just gets pI=cap_net_admin, and fI on ifconfig is cap_net_admin. Now other users (with pI=empty) run ifconfig without privilege, and the limited admin only gets cap_net_admin for ifconfig)

-serge

author maintainer
#14 lore raw
Quoted 51 lines · Serge E. Hallyn
Quoted 33 lines · Eric Paris
Quoted 32 lines · Serge E. Hallyn
Quoted 30 lines · Eric Paris
Quoted 8 lines · Serge E. Hallyn
Quoted 1 line · Eric Paris

type=SYSCALL msg=audit(1224342849.465:43): arch=c000003e syscall=59 success=yes exit=0 a0=25b6a00 a1=2580410 a2=2580140 a3=8 items=2 ppid=2219 pid=2266 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="ping" exe="/bin/ping" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)

This part above is the credentials of the running task, right? Will it output your process inheritable set if nonempty?

(I would think you should be able to test this by doing

Quoted 7 lines
	capsh --inh=cap_sys_admin /bin/sh
	/bin/foo

and look for /bin/foo's record)

thanks,
-serge

For this (patch 2) I'm adding information so you can tell a process escalated it privs with fcaps. This really means you have to audit EXECVE (since this is when fcaps are applied)

setcap "cap_net_admin+pei" /bin/bash
setcap "cap_net_raw+pei" /bin/ping

auditctl -a exit,always -S execve -F path=/bin/ping

type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=1 name=(null) inode=507963 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ld_so_t:s0
type=PATH msg=audit(10/20/2008 13:27:55.318:218) : item=0 name=/bin/ping inode=49227 dev=fd:00 mode=file,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:ping_exec_t:s0 cap_fP=0000000000002000 cap_fE=1 cap_fVer=2 type=CWD msg=audit(10/20/2008 13:27:55.318:218) : cwd=/home/test
type=UNKNOWN[1321] msg=audit(10/20/2008 13:27:55.318:218) : cap_fP=0000000000002000 cap_fI=0000000000000000 cap_fE=1 cap_pP=0000000000001000 cap_pI=0000000000000000 cap_pE=0000000000001000 cap_bprmE=0000000000002000

Quoted 8 lines
Quoted 2 lines

This looks wrong - you say above that you set cap_net_raw in fI for ping, but this shows fI as empty?

/*
* pP' = (X & fP) | (pI & fI)
*/

Not going to disagree that is weird but fcaps aren't inheritable from my

I'm not saying I expected to see them in pP. I'm saying that you report cap_fI as empty. I assume cap_fI should be fI straight out of the xattr. Above you said you put cap_net_raw into fI.

So unless you had actually done 'setcap "cap_net_raw+pe" /bin/ping' before collecting that audit record, it looks like you've got a bug in grabbing fI.

Quoted 9 lines

(As for the way fI is used, you are exactliy right - it is masked against pI then placed in pP'. The idea is that your process can carry ambient privileges which are only enabled if the file lets you, but at the same time are not enabled for tasks which don't have it in pI. So the example I usually use is if you have a limited administrative role which just gets pI=cap_net_admin, and fI on ifconfig is cap_net_admin. Now other users (with pI=empty) run ifconfig without privilege, and the limited admin only gets cap_net_admin for ifconfig)

ok, I thought you were complaining the pI didn't have cap_net_admin. The bug you spotted (I just can't read) was actually me just copy and pasting the wrong thing into this discussion.

I think we all 'sorta' agree on what we want, I'll send 3 final patches in an hour or two when I'm happy they work properly...

1) log fP, fE, fI, fver in PATH records
2) new record to execve when fcaps increase pE or pP
3) new record to capset which records the arguments pid, pP, pI, pE.

-Eric

-Eric

#15 lore raw
Quoted 3 lines · Eric Paris

ok, I thought you were complaining the pI didn't have cap_net_admin. The bug you spotted (I just can't read) was actually me just copy and pasting the wrong thing into this discussion.

Cool, just making sure.

Quoted 6 lines

I think we all 'sorta' agree on what we want, I'll send 3 final patches in an hour or two when I'm happy they work properly...

1) log fP, fE, fI, fver in PATH records
2) new record to execve when fcaps increase pE or pP
3) new record to capset which records the arguments pid, pP, pI, pE.

Great, thanks.

-serge

#6 lore raw
In reply to Eric Paris
Quoted 8 lines · On Monday 20 October 2008 12:55:41 Eric Paris wrote:
Quoted 4 lines

Steve's suggestion of cap_prm and cap_inh are good for being shorter and matching proc output.  But OTOH it's a bit confusing as at first I thought these were the task's values.  Would it be too terse to just use fP and fI?

yes, too terse. How about cap_fP, cap_fI, cap_fVer, cap_fEffBit ?

Based on your other comments I'm going to go add fVer and fEffBit.

We don't have any audit fields with mixed cases in the field name. Let's not start it so that searches stay simple.

Thanks,
-Steve

author maintainer
#7 lore raw
Quoted 6 lines · Steve Grubb
Quoted 5 lines · On Monday 20 October 2008 12:55:41 Eric Paris wrote:
Quoted 4 lines

Steve's suggestion of cap_prm and cap_inh are good for being shorter and matching proc output. But OTOH it's a bit confusing as at first I thought these were the task's values. Would it be too terse to just use fP and fI?

Quoted 6 lines
Quoted 3 lines

yes, too terse. How about cap_fP, cap_fI, cap_fVer, cap_fEffBit ?

Based on your other comments I'm going to go add fVer and fEffBit.

We don't have any audit fields with mixed cases in the field name. Let's not start it so that searches stay simple.

even your /proc example has mixed case :(

so choices

1) cap_fP, cap_fE, cap_fI
2) cap_fp, cap_fe, cap_fi
3) capprm_file, capeff_file, capinh_file

If steve feels strongly about not going down #1 (which obviously I liked!) I vote #2.....

-Eric

#8 lore raw
Quoted 8 lines · On Monday 20 October 2008 19:00:19 Eric Paris wrote:

so choices

1) cap_fP, cap_fE, cap_fI
2) cap_fp, cap_fe, cap_fi
3) capprm_file, capeff_file, capinh_file

If steve feels strongly about not going down #1 (which obviously I liked!) I vote #2.....

Yes, #2 is fine.

Thanks,
-Steve