Bug 853085 - ld.so can be used to bypass audit watches
ld.so can be used to bypass audit watches
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: audit (Show other bugs)
18
Unspecified Unspecified
high Severity unspecified
: ---
: ---
Assigned To: Steve Grubb
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 853068
  Show dependency treegraph
 
Reported: 2012-08-30 09:12 EDT by Steve Grubb
Modified: 2014-02-05 07:07 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-02-05 07:06:58 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Steve Grubb 2012-08-30 09:12:12 EDT
Description of problem:
The audit system is a security requirement in many settings. There are rules that can watch for the execution of certain programs by hooking execve system call inside the kernel. But it turns out that we can't really succeed because of ld.so bypassing execve.

[root@x2 ~]# auditctl -w /usr/bin/ls -p x -k ls
[root@x2 ~]# /lib64/ld-2.15.so /usr/bin/ls /var/run/log/
journal
[root@x2 ~]# ausearch --start recent -k ls
----
time->Mon Aug 20 10:17:10 2012
type=CONFIG_CHANGE msg=audit(1345472230.249:329): auid=4325 ses=2 
subj=unconfined_u:unconfined_r:auditctl_t:s0 op="add rule" key="ls" list=4 res=1
----
time->Mon Aug 20 10:18:05 2012
type=CONFIG_CHANGE msg=audit(1345472285.476:330): auid=4325 ses=2 
subj=unconfined_u:unconfined_r:auditctl_t:s0 op="remove rule" key="ls" list=4 
res=1
[root@x2 ~]# 

It would have been expected that a SYSCALL event would have been logged and another record detailing the passed arguments. Why is the event missed? Execve is never called:

[root@x2 ~]# strace /lib64/ld-2.15.so /usr/bin/ls /var/run/log/
execve("/lib64/ld-2.15.so", ["/lib64/ld-2.15.so", "/usr/bin/ls", 
"/var/run/log/"], [/* 32 vars */]) = 0
brk(0)                                  = 0x7f16ccb7b000
open("/usr/bin/ls", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\2\0>\0\1\0\0\0lK@\0\0\0\0\0"..., 832) 
= 832
fstat(3, {st_mode=S_IFREG|0755, st_size=110032, ...}) = 0
mmap(0x400000, 102400, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|
MAP_DENYWRITE, 3, 0) = 0x400000
mmap(0x619000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_DENYWRITE, 3, 0x19000) = 0x619000
mmap(0x61b000, 672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 
-1, 0) = 0x61b000
close(3)                                = 0

And it keeps going. But the above shows that it reads the executable into 
memory rather than calling execve. Somehow, we need to get an event on watched files.
Comment 1 Siddhesh Poyarekar 2012-10-04 07:36:17 EDT
You'll need to add a special case for ld.so so that whenever it is executed by a user, you look for the arguments to ld.so to decide what was really executed.  That reduces the problem to that of identifying the dynamic linker.  The dynamic linker will typically not have the INTERP in the ELF header.  Also, it will be the only one that has the _start symbol defined.  However, both are true for statically linked binaries as well, so you may have to modify the message you log so that it informs the user that a program has been executed with a different linker.  That or log all static binaries (look for the INTERP) differently, with the commandline arguments.

Either way, I don't think there's much that can be done in the dynamic linker itself.
Comment 2 Jeff Law 2012-10-04 14:17:29 EDT
Or depending on the level of accuracy needed, when an audit watch is set up for exec-ing a particular executable an audit is automatically set up if the same executable is mmap'd.  Obviously in the latter case just because it's mmap'd doesn't mean must be exec'd, it just means it may be exec'd.

But I'm a bit curious, what's to stop someone from bypassing the audit by copying the executable to another location and executing it that way.

Or what's to stop someone from mmaping some pages and using read to fill the pages, then transferring control.

There's probably other ways to get around the audits.  But I agree with SIddhesh, I don't really see there's something here for glibc.
Comment 3 Fedora End Of Life 2013-12-21 03:49:18 EST
This message is a reminder that Fedora 18 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 18. 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 WONTFIX if it remains open with a Fedora 
'version' of '18'.

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 prior to Fedora 18's end of life.

Thank you for reporting this issue and we are sorry that we may not be 
able to fix it before Fedora 18 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 to Fedora 18's end of life.

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 4 Fedora End Of Life 2014-02-05 07:07:03 EST
Fedora 18 changed to end-of-life (EOL) status on 2014-01-14. Fedora 18 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.

Note You need to log in before you can comment on or make changes to this bug.