Hadoop Common
  1. Hadoop Common
  2. HADOOP-8249

invalid hadoop-auth cookies should trigger authentication if info is avail before returning HTTP 401

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0, 2.0.0-alpha
    • Fix Version/s: 1.2.0, 2.0.2-alpha
    • Component/s: security
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      WebHdfs gives out cookies. But when the client passes them back, it'd sometimes reject them and return a HTTP 401 instead. ("Sometimes" as in after a restart.) The interesting thing is that if the client doesn't pass the cookie back, WebHdfs will be totally happy.

      The correct behaviour should be to ignore the cookie if it looks invalid, and attempt to proceed with the request handling.

      I haven't tried HttpFs to see whether it handles restart better.

      Reproducing it with curl:

      ####################################################
      ## Initial curl. Storing cookie to file.
      ####################################################
      
      [root@vbox2 ~]# curl -c /tmp/webhdfs.cookie -i 'http://localhost:50070/webhdfs/v1/?op=LISTSTATUS&user.name=bcwalrus'
      HTTP/1.1 200 OK
      Content-Type: application/json
      Expires: Thu, 01-Jan-1970 00:00:00 GMT
      Set-Cookie: hadoop.auth="u=bcwalrus&p=bcwalrus&t=simple&e=1333614686366&s=z2w5xpFlufnnEoOHxVRiXqxwtqM=";Path=/
      Content-Length: 597
      Server: Jetty(6.1.26)
      
      {"FileStatuses":{"FileStatus":[
      {"accessTime":0,"blockSize":0,"group":"supergroup","length":0,"modificationTime":1333577906198,"owner":"mapred","pathSuffix":"tmp","permission":"1777","replication":0,"type":"DIRECTORY"},
      {"accessTime":0,"blockSize":0,"group":"supergroup","length":0,"modificationTime":1333577511848,"owner":"hdfs","pathSuffix":"user","permission":"1777","replication":0,"type":"DIRECTORY"},
      {"accessTime":0,"blockSize":0,"group":"supergroup","length":0,"modificationTime":1333428745116,"owner":"mapred","pathSuffix":"var","permission":"755","replication":0,"type":"DIRECTORY"}
      ]}}
      
      ####################################################
      ## Another curl. Using the cookie jar.
      ####################################################
      
      [root@vbox2 ~]# curl -b /tmp/webhdfs.cookie -i 'http://localhost:50070/webhdfs/v1/?op=LISTSTATUS&user.name=bcwalrus'
      HTTP/1.1 200 OK
      Content-Type: application/json
      Content-Length: 597
      Server: Jetty(6.1.26)
      
      {"FileStatuses":{"FileStatus":[
      {"accessTime":0,"blockSize":0,"group":"supergroup","length":0,"modificationTime":1333577906198,"owner":"mapred","pathSuffix":"tmp","permission":"1777","replication":0,"type":"DIRECTORY"},
      {"accessTime":0,"blockSize":0,"group":"supergroup","length":0,"modificationTime":1333577511848,"owner":"hdfs","pathSuffix":"user","permission":"1777","replication":0,"type":"DIRECTORY"},
      {"accessTime":0,"blockSize":0,"group":"supergroup","length":0,"modificationTime":1333428745116,"owner":"mapred","pathSuffix":"var","permission":"755","replication":0,"type":"DIRECTORY"}
      ]}}
      
      ####################################################
      ## Restart NN.
      ####################################################
      
      [root@vbox2 ~]# /etc/init.d/hadoop-hdfs-namenode restartStopping Hadoop namenode:                                  [  OK  ]
      stopping namenode
      Starting Hadoop namenode:                                  [  OK  ]
      starting namenode, logging to /var/log/hadoop-hdfs/hadoop-hdfs-namenode-vbox2.out
      
      ####################################################
      ## Curl using cookie jar gives error.
      ####################################################
      
      [root@vbox2 ~]# curl -b /tmp/webhdfs.cookie -i 'http://localhost:50070/webhdfs/v1/?op=LISTSTATUS&user.name=bcwalrus'
      HTTP/1.1 401 org.apache.hadoop.security.authentication.util.SignerException: Invalid signature
      Content-Type: text/html; charset=iso-8859-1
      Set-Cookie: hadoop.auth=;Path=/;Expires=Thu, 01-Jan-1970 00:00:00 GMT
      Cache-Control: must-revalidate,no-cache,no-store
      Content-Length: 1520
      Server: Jetty(6.1.26)
      
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
      <title>Error 401 org.apache.hadoop.security.authentication.util.SignerException: Invalid signature</title>
      </head>
      <body><h2>HTTP ERROR 401</h2>
      <p>Problem accessing /webhdfs/v1/. Reason:
      <pre>    org.apache.hadoop.security.authentication.util.SignerException: Invalid signature</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>                                                
      ...
      
      ####################################################
      ## Curl without cookie jar is ok.
      ####################################################
      
      [root@vbox2 ~]# curl -i 'http://localhost:50070/webhdfs/v1/?op=LISTSTATUS&user.name=bcwalrus'
      HTTP/1.1 200 OK
      Content-Type: application/json
      Expires: Thu, 01-Jan-1970 00:00:00 GMT
      Set-Cookie: hadoop.auth="u=bcwalrus&p=bcwalrus&t=simple&e=1333614995947&s=IXSvPIDbNrqmZryivGeoey6Kjwo=";Path=/
      Content-Length: 597
      Server: Jetty(6.1.26)
      
      {"FileStatuses":{"FileStatus":[
      {"accessTime":0,"blockSize":0,"group":"supergroup","length":0,"modificationTime":1333577906198,"owner":"mapred","pathSuffix":"tmp","permission":"1777","replication":0,"type":"DIRECTORY"},
      {"accessTime":0,"blockSize":0,"group":"supergroup","length":0,"modificationTime":1333577511848,"owner":"hdfs","pathSuffix":"user","permission":"1777","replication":0,"type":"DIRECTORY"},
      {"accessTime":0,"blockSize":0,"group":"supergroup","length":0,"modificationTime":1333428745116,"owner":"mapred","pathSuffix":"var","permission":"755","replication":0,"type":"DIRECTORY"}
      ]}}
      
      1. HDFS-3198_branch-1.patch
        3 kB
        Alejandro Abdelnur
      2. HADOOP-8249.patch
        4 kB
        Alejandro Abdelnur

        Activity

        Arun C Murthy made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Arun C Murthy made changes -
        Fix Version/s 2.0.2-alpha [ 12322473 ]
        Fix Version/s 2.1.0-alpha [ 12321441 ]
        Alejandro Abdelnur made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Fix Version/s 1.2.0 [ 12321659 ]
        Resolution Fixed [ 1 ]
        Arun C Murthy made changes -
        Fix Version/s 2.0.1-alpha [ 12321441 ]
        Fix Version/s 2.0.0-alpha [ 12320352 ]
        Alejandro Abdelnur made changes -
        Affects Version/s 1.1.0 [ 12316501 ]
        Affects Version/s 0.23.1 [ 12318884 ]
        Alejandro Abdelnur made changes -
        Attachment HDFS-3198_branch-1.patch [ 12521809 ]
        Alejandro Abdelnur made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Alejandro Abdelnur made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Hadoop Flags Reviewed [ 10343 ]
        Resolution Fixed [ 1 ]
        Alejandro Abdelnur made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Fix Version/s 2.0.0 [ 12320352 ]
        Alejandro Abdelnur made changes -
        Attachment HADOOP-8249.patch [ 12521475 ]
        Alejandro Abdelnur made changes -
        Summary webhdfs does not honour its own cookies invalid hadoop-auth cookies should trigger authentication if info is avail before returning HTTP 401
        Assignee Alejandro Abdelnur [ tucu00 ]
        Alejandro Abdelnur made changes -
        Field Original Value New Value
        Project Hadoop HDFS [ 12310942 ] Hadoop Common [ 12310240 ]
        Key HDFS-3198 HADOOP-8249
        Affects Version/s 0.23.1 [ 12318884 ]
        Affects Version/s 2.0.0 [ 12320352 ]
        Affects Version/s 0.23.1 [ 12318885 ]
        Component/s security [ 12312526 ]
        Component/s name-node [ 12312926 ]
        bc Wong created issue -

          People

          • Assignee:
            Alejandro Abdelnur
            Reporter:
            bc Wong
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development