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

fapolicyd and ansible permission deny #311

Open
mcknight1981 opened this issue Jul 9, 2024 · 6 comments
Open

fapolicyd and ansible permission deny #311

mcknight1981 opened this issue Jul 9, 2024 · 6 comments

Comments

@mcknight1981
Copy link

I am running a simple ansible-playbook -i inventory.ini -b playbook.yaml, without fapolicyd running all the ping's are successful, when i activate the policy, I get this:
[WARNING]: sftp transfer mechanism failed on [xxx.xx.xxx.xxx]. Use ANSIBLE_DEBUG=1 to see detailed information
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: PermissionError: [Errno 1] Operation not permitted: b'/usr/home/xxxxx/.ansible/tmp/ansible-local-30386wpmj2n12/tmp75p3z00c'
fatal: [xxx.xx.xxx.xxx]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}

I don't know how to fix this, i have added the file to trust.d and still wont work

@radosroka
Copy link
Member

You are using ansible with ansible user which is not supported by default. If you use root there should be no problem if that's not possible you can allow just specific directory.

@skosachiov
Copy link
Contributor

E.g.: exception for system, first local user and ansible user:
https://github.com/skosachiov/remediations-gendbuntu/blob/main/roles/fapolicyd/templates/25-system-auid.rules.j2
See ansible fapolicyd role templates:
https://github.com/skosachiov/remediations-gendbuntu/tree/main/roles/fapolicyd
Tasks: mask fapolicyd (to avoid start on debian), install fapolicyd, copy config/rules/trusts, unmask, start fapolicyd.

@mcknight1981
Copy link
Author

mcknight1981 commented Jul 26, 2024

I will take a look at both of these, the problem is we are not able to be root and run ansible, it must be the user. Its a security thing we have. We are able to use root to escalate in the playbook become = yes.

@skosachiov
Copy link
Contributor

Auid (not uid) ID is assigned to a user upon login and is inherited by every process even when the user's identity changes (for example, by switching user accounts with su - root), thus for username ansible:

...
allow perm=execute auid=ansible all : all
allow perm=execute all : all trust=1 
...
allow perm=any auid=ansible : ftype=text/x-python
allow perm=any all : ftype=text/x-python trust=1 
...
allow perm=open auid=ansible : ftype=application/x-bytecode.python
allow perm=open all : ftype=application/x-bytecode.python trust=1
...
deny_syslog perm=execute all : all
deny_syslog perm=any all : ftype=text/x-python
deny_syslog perm=any all : ftype=application/x-bytecode.python

Regular users can only run trusted files.

@mcknight1981
Copy link
Author

Do i need to make an ansible user profile?

@skosachiov
Copy link
Contributor

Creating a separate Local account, such as "ansible", with key-based authentication can be very useful for managing a large fleet of hosts. Domain authentication can fail at the most inopportune moment.

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