Velocidex / velociraptor

Digging Deeper....
https://docs.velociraptor.app/
Other
2.8k stars 469 forks source link

Support automatic user creation with SAML authentication #3551

Closed ZauberNerd closed 1 month ago

ZauberNerd commented 1 month ago

With this change we are able to automatically create users for SAML authenticated users and assign them roles. Before this change, users had to be created manually on the velociraptor server, even when using SAML authentication, which lead to double book keeping.

Based on the work in the certs authenticator module:

Instead of reusing the gui.authenticator.default_roles_for_unknown_users field we introduced a new saml_user_roles field to ensure privilege separation between gui users and client certificates.

CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.

scudette commented 1 month ago

Thanks for this pr. I was a bit reluctant to automate user creation based on saml or oauth because that can have unintended effects. For example any user that's authenticated by saml may automatically get access to velociraptor.

Typically the teams that manage velociraptor access are not the same as teams that manage user accounts and I can see accidents happening with users automatically created in velociraptor.

I guess if it's very clearly documented and people understand the risk then it's fine but how likely is it to have this kind of mistake?

ZauberNerd commented 1 month ago

@scudette if the authenticator.saml_user_roles config is not set, then no users will be created. You could then create administrator accounts manually and afterwards enable SAML role assignment with less privileged accounts. I have updated the documentation and comments to mention this behavior. Do you think that is good enough?

In a future iteration, we could think about adding a configuration setting to allow using other SAML attributes to map for example groups to policies. What do you think?

scudette commented 1 month ago

This is what I was asking being not very familiar with SAML administration - does SAML allow the application to be assigned to a user or does it mean that anyone who is able to authenticate to SAML anywhere in the domain can also log into the velociraptor app (and therefore get automatically created?)

With OAUTH this is actually the case - for example, if we use Google to implement OAuth then literally anyone who can authenticate to Google (e.g. random Gmail user) will be able to return from the oauth handler and pass into AuthenticateUserHandler() callback. They will normally be stopped in the user account check, but if the expectation is that an account will be automatically provisioned then anyone that creates a gmail account will get a login!

zined commented 1 month ago

This is what I was asking being not very familiar with SAML administration - does SAML allow the application to be assigned to a user or does it mean that anyone who is able to authenticate to SAML anywhere in the domain can also log into the velociraptor app (and therefore get automatically created?)

from my (probably rather limited) experience with SAML identity providers, "filtering" users per application seems to be a very standard functionality included almost everywhere. At least AD-FS/Keycloak/AWS Identity Center all have logic to "map" users to an application based on group-memberships or other factors, therefore limiting permitted users to a subset of all users already. From my point of view, having any mapping/filtering logic inside the IDP vs. inside the SP is highly desirable to (a) keep it simple and (b) not have a lot of distributed filter mechanisms throughout your application landscape, but rather in a central place.

EDIT: don't get me wrong, i totally believe having logic to map separate roles inside velociraptor to users based on SAML attributes makes a lot of sense in a more complex organizational structure where you need different users to have different roles inside your velociraptor setup, but I believe it would make sense to implement this in a separate PR.