Introduction / Motivation

Apache Knox 0.14.0 introduces the ability to manage topology deployments across multiple gateway instances by modifying znode contents in Apache ZooKeeper.

Due to the sensitive nature of some of the content, and the potential for an untrusted actor to intentionally provide malicious configuration, it is highly recommended that the ZooKeeper node(s) require authentication, and that the znodes used by Knox have appropriate ACLs applied.

This article will describe the minimal configuration necessary to accomplish this, and demonstrate the application of digest-backed(for simplicity) SASL authentication.


SASL Authentication

SASL is a framework for applications to add authentication support by way of a variety of authentication mechanisms. ZooKeeper employs SASL.
The Knox remote configuration registry facility currently supports the Kerberos and DIGEST-MD5 mechanisms for ZooKeeper interactions.

The ZooKeeper server and client use the Java Authentication and Authorization Service (JAAS) and the associated configuration to apply authentication.


RemoteConfigurationRegistryClient Configuration

Knox clients for remote configuration registries (e.g., ZooKeeper) are configured in {GATEWAY_HOME}/config/gateway-site.xml.

Each client configuration is a single property, the name of which is prefixed with gateway.remote.config.registry. , and suffixed by the client identifier. The value of such a property, is a registry-type-specific set of semicolon-delimited properties for that client, including the type of registry with which it will interact.

This configuration is the means by which the supported authentication mechanisms can be specified for each client.

N.B., Due to a limitation of the ZooKeeper client, there can only be a single secure ZooKeeper client configured for Knox at any given time. This will be resolved subsequent to the release of ZooKeeper 3.6.0, such that multiple ZooKeeper clients with distinct authentication configuration can be defined.

The configuration for a single-node ZooKeeper, without any client authentication required, looks similar to this:


    <description>ZooKeeper configuration registry client details.</description>

This article will be limited to a single-node ZooKeeper for these reasons:

  • The ZooKeeper available in the HDP Sandbox is a single-node.
  • The focus of this article is on the secure client configuration, and ensemble-level security configuration is beyond that scope.


For interactions with a ZooKeeper that requires client authentication, some additional properties need to be added to the client configuration.

This is the DIGEST-MD5 configuration:

    <description>ZooKeeper configuration registry client details.</description>


You'll notice that the following have been added to the property value:

  • authType The Digest value is what specifies that the client will attempt to authenticate via the DIGEST-MD5 mechanism.
  • principal The identity, as which the client is requesting to be authenticated.
  • credentialAlias A gateway alias for the password associated with the principal.

More details about these client configurations are available in the User Guide.


ZNode ACLs

By default, znodes have effectively no restrictions (i.e., world:anyone:cdrwa) on their ability to be modified. This poses a problem for an application like Knox, which needs to trust the content of one or more znodes. If anyone can create configuration, then there is the potential that Knox could consume and apply malicious configuration. Measures need to be taken to ensure that the ability to create or modify configuration is limited to trusted actors. Once such measure is the application of more restrictive ACLs.

An ACL specifies a set of znode permissions for a user. At the very least, write permissions should be limited to authenticated users. I would further suggest that read permissions be similarly limited, since the gateway configuration does contain Hadoop cluster network details.

Fortunately, when the Knox ZooKeeper client is configured for authentication, the remote registry monitor will make appropriate changes to the ACLs for the znodes with which it is concerned.


Try it!

  1. HDP Sandbox (

  2. Configure ZooKeeper JAAS
    1. Create JAAS configuration (e.g., sasl-zk-jaas.conf) with content:
      Server {     org.apache.zookeeper.server.auth.DigestLoginModule required     user_knox="knoxtest"; };
    2. Edit (e.g., /usr/hdp/current/zookeeper-server/conf/, adding a reference to the JAAS config you just created

      export SERVER_JVMFLAGS="-Xmx1024m

    3. Edit zoo.cfg (e.g., /usr/hdp/current/zookeeper-server/conf/zoo.cfg), adding the following:


    4. Restart ZooKeeper (e.g., '/usr/hdp/current/zookeeper-server/bin/ start')

  3.  Create the Knox configuration znodes
    1. Create a client JAAS config (e.g., sasl-zk-client-jaas.conf)

      Client {
          org.apache.zookeeper.server.auth.DigestLoginModule required

    2.  export

    3.  {ZOOKEEPER_HOME}/bin/ -server

      create /knox "1"
      create /knox/config "1"
      create /knox/shared-providers "1"
      create /knox/config/descriptors "1"
      setAcl /knox/config/shared-providers sasl:knox:cdrwa
      setAcl /knox/config/descriptors sasl:knox:cdrwa

  4. Configure the client in {GATEWAY_HOME}/conf/gateway-site.xml (no authentication config)

        <description>ZooKeeper configuration registry client details.</description>


  5. bin/ registry client should not work because of no authentication

    {GATEWAY_HOME}/bin/ upload-descriptor mysandbox.yml --registry-client sandbox-zookeeper-client

  6. Create the ZK auth password alias

    {GATEWAY_HOME}/bin/ create-alias sandbox-zk-pwd --value knoxtest

  7.  Add auth to the client config in {GATEWAY_HOME}/conf/gateway-site.xml

        <description>ZooKeeper configuration registry client details.</description>

  8.  bin/ registry client should succeed now that authentication is configured

    {GATEWAY_HOME}/bin/ upload-descriptor mysandbox.yml --registry-client sandbox-zookeeper-client


Hopefully, this helps provide some understanding of what is required to secure the interactions between the gateway and Apache ZooKeeper.

The [Remote Configuration Registry Clients]( section of the [User Guide]( provides more information, including the details necessary to configure Kerberos authentication for these interactions.


Bonus Tip

If you get in a bad place with respect to ACLs and authentication errors, you can configure super user support:

1. export ZK_CLASSPATH=/etc/zookeeper/conf/:/usr/hdp/current/zookeeper-server/lib/*:/usr/hdp/current/zookeeper-server/*


2. java -cp $ZK_CLASSPATH org.apache.zookeeper.server.auth.DigestAuthenticationProvider super:superpwd


3. SERVER_JVMFLAGS=-Dzookeeper.DigestAuthenticationProvider.superDigest=super:G+ys1zTeJy/1iLhgQS08pRQoMvo=


4. Restart ZooKeeper







  • No labels