Skip to content

whitelist_modules on the minion blocks internal module composition, forcing all-or-nothing security #69983

Closed

Description

@dwoz

Problem

Salt has a whitelist_modules setting on the minion that restricts which
execution modules a remote caller can invoke. It looks like exactly what you
want when you don't fully trust the master and only need to expose a small
surface (say test.ping, saltutil.sync_*, and a couple of company modules).

In practice it's unusable, because almost every built-in Salt module reaches
for cmd (or config, grains, pillar, etc.) internally via __salt__[...].
If you whitelist your custom module but not cmd, your module fails at runtime
even though the caller never asked for cmd.

Example

# /etc/salt/minion
whitelist_modules:
  - test
  - mycompany
  - saltutil

salt '*' mycompany.deploy fails, because mycompany.deploy internally does
__salt__['cmd.run'](...). Two bad options remain:

  • Add cmd to the whitelist — now the master can also publish
    salt '*' cmd.run 'rm -rf /', so the whitelist stopped protecting anything.
  • Rewrite the module to bypass the loader (import salt.modules.cmdmod) —
    ugly, and it defeats other loader-level checks too.

History

Same trap has been reported twice and closed with no fix:

What should happen

whitelist_modules should only restrict what a remote caller can invoke.
Modules calling each other via __salt__ should keep working. This is the
intent behind the feature but was never fully delivered.

Fix

PR #69974 makes exactly that behavior true:

  • Remote callers see only the whitelisted modules
  • Whitelisted modules can still call any other module via __salt__ (so
    mycompany.deploy keeps working with cmd.run off the whitelist)
  • Direct remote publish of a non-whitelisted module is still refused

Combined with the existing cmd_blacklist_glob (which lets you additionally
block specific command strings like *rm -rf*), this closes both the
coarse-grained ("keep cmd off the wire") and fine-grained ("block this
specific command") halves of the ask in #52592.

Activity

  1. added 5 commits that reference this issue on Aug 10, 2026
    fe4b90f
    a320081
    7781e86
    2ed6766
    f69038a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions