Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what does a subject of "exe=/" mean? #238

Open
ehousey opened this issue Apr 17, 2023 · 10 comments
Open

what does a subject of "exe=/" mean? #238

ehousey opened this issue Apr 17, 2023 · 10 comments

Comments

@ehousey
Copy link

ehousey commented Apr 17, 2023

Hi, I recenty installed fapolicyd and started using it. One thing I noticed is that in order to enforce fapolicyd on an EKS worker node, I had to add 3 lib64 libraries (the objects of an allow rule) with a subject of "exe=/" and an object of "path=/usr/lib64/some_lib.

What does a subject of "exe=/" mean? According to the fapolicyd documentation that I referenced (https://www.mankier.com/5/fapolicyd.rules), the subject that is defined by "exe" is "The full path to the executable.". The object with "path=" is defined as "This is the full path to the file that will be accessed."

It is not clear to me what a subject of "exe=/" means.

Is this a bug?

@stevegrubb
Copy link
Member

It's not a rule we ship. So, I'd bounce it back to you. What were you trying to do with that rule? Why was it needed? It likely is a no-op since it will never match. Fapolicyd does not validate rules point to anything that exists (so that you can write rules for things that get mounted later). It just checks syntax. fapolicyd-cli on the other hand does some level of validation but it wouldn't see this. fapolicy-analyzer probably would see this as a problem since it does rule linting.

@ehousey
Copy link
Author

ehousey commented Apr 18, 2023 via email

@stevegrubb
Copy link
Member

The exe=/ is invalid. There cannot be an executable that is the root directory. I have seen issues like this when the overlay file system is in use. It takes a newer version of fapolicyd (1.1.7 or later) to correctly handle overlayfs and bind mounts. But then you may have other problems with containers since fapolicyd has no data source for them.

I don't know why any denies would be missing. Maybe the invalid paths or something that was fixed after the version you are running.

Yes, you can turn off the rpmdb and manage your own trustdb. Just set trust = file. Then add files like this fapolicyd-cli --file add /usr/local/bin. Also, to make managing things better, we have a /etc/fapolicyd/trust.d/ where you can drop off preconfigured trust based on the applications you install or update.

Also, rpm and dnf can validate rpm signatures and not allow installation if the signature check fails. fapolicyd only accepts rpm info that passes rpm's integrity checks.

@ehousey
Copy link
Author

ehousey commented Apr 20, 2023 via email

@stevegrubb
Copy link
Member

That rule does not consider trust. (You can hexedit the file and it will still allow it.) Therefore an entry in the trustdb is not needed. However, without the trust entry, you cannot tell if the file has been replaced with something that is not what you expect. It really just depends on your threat model and whether integrity testing should be done.

If you do want integrity checking, you need to enable what kind of checking such as sha256 or size. Then you need an entry in the trustdb. Then you need to add trust=1 on the object side for the rule.

If you are running in debug mode with it in the foreground, it won't log to the audit logs. Also, the audit system in the kernel has some performance optimization where if there are no audit rules loaded, then it does away with certain classes of audit events. To check it, run auditctl -l. If you don't have any rules, add at least one (maybe watch the shadow file for writes? -F path=/etc/shadow -F perm=w) and restart the audit daemon to make it load rules. This is not a fapolicyd issue, it's how the audit system works.

allow_log/deny_log means send the event to both places for good measure.

@ehousey
Copy link
Author

ehousey commented Apr 20, 2023 via email

@paulrosberg
Copy link

paulrosberg commented Jun 21, 2023

Have a similar issue with fapolicyd and a docker install.
Get these blocks about 30% of the times I issue a specific command to a container (performing a kill for nginx log rotation):

rule=6 dec=deny_audit perm=open auid=-1 pid=709023 exe=/ : path=/usr/lib64/libseccomp.so.2.5.2 ftype=application/x-sharedlib trust=1
rule=6 dec=deny_audit perm=open auid=-1 pid=709108 exe=/ : path=/usr/lib64/libseccomp.so.2.5.2 ftype=application/x-sharedlib trust=1

Tried abut 10 different rules to allow it with a rule but no go. It seems to totally reject any rules trying to match the above deny.
The default rule in 30-patterns.rules catch it everytime.
deny_audit perm=any pattern=ld_so : all

So ended up having to add the file /etc/fapolicyd/rules.d/29-docker.rules with this rule that basically whitelist everything for now:
allow perm=open all : all

Super ugly but whatever "exe=/" is, it seems to totally confuse fapolicyd.

@stevegrubb
Copy link
Member

The problem with any containers is that they typically bind mount onto the file system which causes a change in visibility. (The fanotify API is namespace unaware.) And then depending on how many namespaces they have, there may be nothing in /proc to examine. I have to think there is an alternate way to introspect running containers, but fapolicyd does not support containers at the moment.

@paulrosberg
Copy link

paulrosberg commented Jun 30, 2023

but fapolicyd does not support containers at the moment.

Thanks for that piece of information, will remove fapolicyd for machines running containers.

@stevegrubb
Copy link
Member

That would be my advice at this point. Containers may be supported in the future. But that would also be dependent on them having a manifest that is detailed enough to reason about their integrity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants