如何在hdfs nfsgateway中避免潜在的用户模拟?

uidvcgyl  于 2021-05-29  发布在  Hadoop
关注(0)|答案(0)|浏览(138)

使用hdfs-nfsgateway似乎有一个安全缺陷(我使用的是hdp3.1.4),我不知道如何解决它(不太熟悉网络或安全性等)。下面是一个例子:
一些在自己的机器上具有root访问权限的用户可以通过nfsgateway访问hdfs(即,将其安装到自己的机器上)
然后,它们使一个用户的uid与要模拟的用户在hadoop集群节点上的uid相同
他们 su 并访问用户的安装版本 hdfs:///user/<username> 此计算机上的文件夹(用户不必作为客户端计算机上的根用户访问)
如。

[root@HW006 user]# #Here is a mounted HDFS NFSGateway
[root@HW006 user]# ls -lh /hdpnfs/user/
total 5.0K
drwx------. 3        1008         1004  96 Sep 11 14:53 accumulo
drwxrwx---. 9        1019         1004 288 Sep 11 15:17 ambari-qa
drwxr-xr-x. 3        1018         1006  96 Sep 11 14:54 druid
drwxr-xr-x. 2        1010         1004  64 Sep 11 14:53 hbase
drwxr-xr-x. 2        1000         1004  64 Sep 11 14:52 hive
drwxrwxr-x. 3        1013         1004  96 Sep 11 15:00 oozie
drwxrwxr-x. 2        1009         1004  64 Sep 11 15:07 spark
drwxr-xr-x. 3 testuser001 hdptestusers  96 Sep 12 13:44 testuser001
drwxrwx---. 4        1001         1006 128 Sep 11 14:50 yarn-ats
drwxr-xr-x. 5        1015         1004 160 Sep 11 14:51 zeppelin
[root@HW006 user]#
[root@HW006 user]#
[root@HW006 user]#
[root@HW006 user]# # Now I'll make a user to impersonate the oozie user
[root@HW006 user]# useradd --uid 1015 --no-create-home imposteruser
[root@HW006 user]# ls -lh
total 5.0K
drwx------. 3         1008         1004  96 Sep 11 14:53 accumulo
drwxrwx---. 9         1019         1004 288 Sep 11 15:17 ambari-qa
drwxr-xr-x. 3         1018         1006  96 Sep 11 14:54 druid
drwxr-xr-x. 2         1010         1004  64 Sep 11 14:53 hbase
drwxr-xr-x. 2         1000         1004  64 Sep 11 14:52 hive
drwxrwxr-x. 3         1013         1004  96 Sep 11 15:00 oozie
drwxrwxr-x. 2         1009         1004  64 Sep 11 15:07 spark
drwxr-xr-x. 3 testuser001  hdptestusers  96 Sep 12 13:44 testuser001
drwxrwx---. 4         1001         1006 128 Sep 11 14:50 yarn-ats
drwxr-xr-x. 5 imposteruser         1004 160 Sep 11 14:51 zeppelin
[root@HW006 user]#
[root@HW006 user]#
[root@HW006 user]#
[root@HW006 user]# # Now lets see if imposteruser is able to write to the hdfs:///user/zeppelin directory
[root@HW006 user]# su imposteruser
bash-4.2$ pwd
/hdpnfs/user
bash-4.2$ cd zeppelin/
bash-4.2$ pwd
/hdpnfs/user/zeppelin
bash-4.2$ ls
conf  notebook  test
bash-4.2$ touch tmp.txt
bash-4.2$ ls -lh
total 1.5K
drwxr-xr-x. 3 imposteruser 1004  96 Sep 12 11:50 conf
drwxr-xr-x. 4 imposteruser 1004 128 Sep 11 14:51 notebook
drwxr-xr-x. 2 imposteruser 1004  64 Sep 11 14:51 test
-rw-r--r--. 1 imposteruser 1004   0 Sep 13 12:12 tmp.txt
bash-4.2$ exit
exit
[root@HW006 user]#
[root@HW006 user]#
[root@HW006 user]#
[root@HW006 user]# # Lets go to a cluster node and see how it looks from there
[root@HW006 user]# ssh hw001
root@hw001's password:
[root@HW001 ~]# hadoop fs -ls /user/zeppelin
Found 4 items
drwxr-xr-x   - zeppelin hdfs          0 2019-09-12 11:50 /user/zeppelin/conf
drwxr-xr-x   - zeppelin hdfs          0 2019-09-11 14:51 /user/zeppelin/notebook
drwxr-xr-x   - zeppelin hdfs          0 2019-09-11 14:51 /user/zeppelin/test
-rw-r--r--   3 zeppelin hdfs          0 2019-09-13 12:12 /user/zeppelin/tmp.txt
[root@HW006 user]#
[root@HW006 user]#
[root@HW006 user]# # So you can see that it looks as is the user zeppelin created the tmp.txt file, when really it was the imposteruser on the NFSGateway-accessing server.

是否有任何建议的/最佳实践的方法来阻止这种情况(尽管仍然允许客户机上的用户访问他们需要访问的hdfs文件夹)?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题