Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-20544

TOpenSessionReq logs password and username


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.0.0
    • Fix Version/s: 4.0.0
    • Component/s: Hive
    • Target Version/s:
    • Flags:
      Patch, Important


      In service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TOpenSessionReq, if client protocol is unset, validate() and toString() prints both username and password to logs.

      Logging a password is a security risk. We should hide the *******.

      =====Edit===== (no longer relevant, see comments)

      This issue is tricky since it is caused in a fully generated class. I've been playing around and have found one working solution, butI'd truly appreciate ideas for a more elegant solution or input.

      The problem:
      TCLIService.thrift is the template for generating all classes in service-rpc. Struct TOpenSessionReq is OpenSession()'s one parameter and is defined thus:

      struct TOpenSessionReq {
        1: required TProtocolVersion client_protocol = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V10
        2: optional string username
        3: optional string password
        4: optional map<string, string> configuration

      In the generated class TOpenSessionReq.java, client_protocol is checked by a validate() method, which is called quite a few times; if client_protocol is not set, it throws a TProtocolException, passing along a toString(). This toString() gets the names and values of all fields, including username and password.

      Working solution:

      • Create a separate struct containing only the username and password, and pass it to OpenSession() as a second parameter. Since all fields in the new struct are "optional", the generated validate() is empty – toString() is never used. This involves changing core classes and breaks the "Each function should take exactly one parameter" coding convention (detailed at service-rpc/if/TCLIService.thrift:27).
        See working-solution.patch.

      What doesn't work:

      • Making client_protocol optional instead of required. Apparently this will break everything.
      • Overwriting toString() – TOpenSessionReq is a struct.
      • Creating two Thrift structs, one struct for required (TRequiredReq) and one for optional (TOptionalReq) fields, and nesting them in struct TOpenSessionReq. This doesn't work because validate() in TOpenSessionReq can call TOptionalReq.toString(), which prints the password to logs. This will happen if TRequiredReq.client_protocol isn't set.
        See non-solution.patch
      • Asking Thrift devs to change their code. I wrote them an email but have no expectations.


        1. working-solution.patch
          160 kB
          Karen Coppage
        2. non-solution.patch
          170 kB
          Karen Coppage
        3. HIVE-20544.patch
          0.7 kB
          Karen Coppage
        4. HIVE-20544.4.patch
          7 kB
          Karen Coppage
        5. HIVE-20544.4.patch
          7 kB
          Karen Coppage
        6. HIVE-20544.4.patch
          7 kB
          Karen Coppage
        7. HIVE-20544.4.patch
          7 kB
          Karen Coppage
        8. HIVE-20544.4.patch
          7 kB
          Karen Coppage
        9. HIVE-20544.4.patch
          7 kB
          Karen Coppage
        10. HIVE-20544.3.patch
          5 kB
          Karen Coppage
        11. HIVE-20544.3.patch
          5 kB
          Karen Coppage
        12. HIVE-20544.2.patch
          4 kB
          Karen Coppage
        13. HIVE-20544.1.patch
          0.7 kB
          Karen Coppage

          Issue Links



              • Assignee:
                klcopp Karen Coppage
                klcopp Karen Coppage
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: