Repository navigation
Description
When I contributed the splay module in #22835 I did not consider that it would potentially allow a user to run a command from a blacklisted module, since 'splay.splay' is what ends up being checked against the ACL rather than the function passed as an argument.
My reasoning behind implementing splay as module was basically (1) simplicity of implementation and use, and (2) so that the hash calculations would be offloaded to the minions...calculating thousands of hashes on the master all at once would kind of defeat the purpose of splaying in the first place :)
Since the blacklist exists within the masters opts, there is no way for a minion (AFAIK) to have access to the blacklist, which precludes us from doing blacklist filtering inside the module itself, making this more complicated. I have a few ideas on how this could be resolved, so I wanted to check what preference, if any, the Salt team has before submitting a pull request.
I personally lean towards the module implementation. At first blush, this would require the master to somehow be aware of 'wrapper' modules as distinct from other modules so that it can check the function being wrapped against the client blacklist. A simple way to accomplish this could be to require that wrapper modules fulfill certain requirements, like having a specific kwarg for the wrapped function that the master knows to run through ClientACL().cmd_is_blacklisted(), but that might be a little hacky.
Another option would be to diverge from the module implementation and reimplement as a CLI option more in line with the current implementation of batch. The obvious plus side of this is that it would negate any need to alter how the master checks functions against the blacklist.
Sorry for my oversight when submitting the module! I hope that we can find an agreeable way to integrate this functionality, as I've found it incredibly useful.
Activity
jfindlay commentedon Apr 29, 2015
@Jodv, thanks for working on this.
@thatch45, @cachedout, @garethgreenaway
cachedout commentedon May 5, 2015
@Jodv Thanks for the excellent synopsis here. I have a few comments.
This limitation of blacklists isn't really unique to the splay module. There are many, modules which cross-call each other. Your analysis of the master-side limitation of client_acl blacklists here is dead-on. In fact, this quickly becomes a fairly unwieldly dependency graph as any single salt module function can result in many downstream calls. As a result, I feel like designating certain modules as "wrappers" would be difficult to maintain. (If I'm reading your suggestion correctly, that is.)
Ultimately, I feel like we need to support client_acl on the minion side and enforce things there in order to solve this properly. Even there, however, we'd run into trouble as we'd potentially abort a top-level function mid-way through if it encountered a function it wasn't allowed access to.
In reality, I think the most practical thing we can do today is to ensure that the documentation about module blacklisting includes this type of information so that users can decide if blacklisting is an approach that truly meets their security requirements.
Thoughts?
jeremyrosenbaum commentedon May 6, 2015
Thanks for the follow up @cachedout ... I agree that my initial off-the-top-of-my-head suggestion about having some special logic for wrapper modules is probably a Bad Idea™, however I think the approach of documenting the risk and leaving it be is problematic because, like you said, the splay module is not the only place where this happens. I'd venture to say that almost anyone who would be interested in the blacklist as a security feature would find it lacking if circumventing it is as simple as running a wrapper module.
I've been thinking that a reasonable way to extend the module blacklist to minions would be to inject the blacklist data into pillar returns from the master and have logic in the LazyLoader that skips loading modules in the blacklist pillar (much like it skips modules not in the whitelist, if a whitelist is defined). The concern I have is that, if we were to make this change, we would be essentially changing the definition of what a blacklisted module is from "a module that cannot be targeted for execution via LocalClient methods" to "a module that cannot be targeted for execution via any means". In doing so, we would risk breaking custom modules in environments with the module blacklist. I think there are legitimate use cases for a custom module to be able to call a given module function in a controlled way, but not allow that same module function to be run manually by users with the CLI or API.
I think a step in the right direction at least would be to inject the module blacklist into pillar returns so that minions can at least have the data and then rely on "wrapper" modules like splay to check for the blacklist data in the pillar before they execute wrapped commands. That would prevent us from breaking existing cross-module calls while giving us the ability to lock them down where it makes sense. If there is demand for it at some point in the future, I think it would be fairly easy from there to add an additional master config option for the blacklist as to whether or not the blacklist should prevent any cross-module calls whatsoever, pass that in the pillar with the blacklist and have the LazyLoader respect the blacklist if that option is set.
Let me know your thoughts. Thanks!
cachedout commentedon May 13, 2015
@Jodv I think you're heading in the right direction here. I'd like to bring some additional voices into the discussion here as well.
cc: @thatch45, @msteed, @jacksontj
msteed commentedon May 13, 2015
I think the only way that blacklist functionality makes sense is if it applies regardless of how a module is invoked.
I understand the concern about breaking current use cases, but to me it would be an unpleasant surprise to find a blacklisted module working under any circumstance. The example in the docs is described as blacklisting "any use" of the cmd module.
If there is a need for less of a sledgehammer approach to module access control, my suggestion is that we consider some other mechanism in addition to a blacklist.
I like the pillar + LazyLoader solution.
garethgreenaway commentedon May 13, 2015
I agree with @msteed on this. If a module is blacklisted then it shouldn't be callable, at all. Being able to circumvent that and call the module, negates the whole purpose of having the blacklist. I like the idea of including the list of blacklisted as well as being able to check which modules are being called via mechanisms like splay against that list.
jacksontj commentedon May 15, 2015
I think there is a bit of confusion on the blacklisting here. The issue @Jodv is bringing up is in relation to client_acl_blacklist (http://docs.saltstack.com/en/latest/ref/configuration/master.html#client-acl-blacklist) which IIRC I had pushed upstream. The intent implementation of that feature gives you access control on Salt's publishing interface, not within modules etc. The intent was to allow an administrator to block certain users from running certain commands through remote execution (primarily to avoid "fat fingering" scary looking commands-- such as cmd.run).
It sounds like @msteed and @garethgreenaway are looking for a slightly different blacklist-- specifically that they can configure certain modules to never be loaded (or at least certain functions)-- which I thought we had implemented, but it looks like we don't actually have that (it would be trivial to add).
So from my perspective this client_acl_blacklist feature might need to be renamed (since it is completely intended as publish only acls-- same as client_acl, so maybe it would be better called publisher_acl and publisher_acl_blacklist?). To fix that I think we'd actually need to pull splay into the core such that it is another flag on the load going to the minion. That way we don't have to try and unwind the nested module calls to see which one is the module we allow/disallow. It kinda seems like we want something like a "module executor" flag which can switch between immediate, splay, random, sleep N, etc.
As for the actual module blacklisting I think we should open up a feature request for that-- if we want that I'd be more than happy to add it (since I did all the loader stuff)-- and we can definitely make that similar to how we do _schedule (meaning it merges config and pillar data) because I think that'd be awesome.
DmitryKuzmenko commentedon Aug 3, 2015
I like @jacksontj idea to make configurable "module executor" load argument handling on the Minion side. It's not the answer to the acl question but looks as a core execution feature. I'm working in this way.
1 remaining item
DmitryKuzmenko commentedon Oct 12, 2015
Module executor approach is implemented and I have some question here:
client_acltopublisher_aclas @jacksontj proposed?basepi commentedon Oct 14, 2015
I think we should probably do so at some point. It will require a long deprecation path and careful documentation. Or I'd also be fine if we just stuck big warnings all over all the documentation of client_acl stating what it actually does, so nobody gets caught by this.
This should be a new issue, and I think we can let @jacksontj implement it, since he volunteered. ;)
Thanks @DmitryKuzmenko!
DmitryKuzmenko commentedon Oct 22, 2015
@basepi sent PR deprecating client_acl with publisher_acl. Could you please review it mainly in the documentation part:
DmitryKuzmenko commentedon Oct 22, 2015
Created the blacklisting task.
Work is done here.