All of lore.kernel.org
 help / color / mirror / Atom feed
* nfs root directory security
@ 2003-06-17 22:28 Scott Leerssen
  2003-06-17 23:36 ` Neil Brown
  0 siblings, 1 reply; 13+ messages in thread
From: Scott Leerssen @ 2003-06-17 22:28 UTC (permalink / raw)
  To: nfs

[-- Attachment #1: Type: text/plain, Size: 976 bytes --]

Attached is a patch for nfs-utils-1.0.1-2.9 (RedHat) that adds a bit of
security and ease of use for exported filesystems that have lots of
users in lots of subdirectories.

What it does is disallow nfs clients from mounting a directory that is
marked execute only (chmod 0111), controlled by an option
"root_mnt_orig".  This is handy if one has a constantly changing
hierarchy of subdirectories where the client is the only one who knows
where to look for his stuff.  Consider a directory structure that looks
like:

/A/B/C/123
/A/B/C/456
/A/B/C/789

If A, B and C are mode 0111, the nfs client must directly mount 123,
456, or 789.  OK, this is a kind of lame example, but one can easily add
some obscurity to the directory structure under /A and see how
effectively this hides NFS mount points and adds some ease of use when
maintaining a TON of mount points.

Enjoy, and feel free to come up with an option name that doesn't suck.

-- 
Scott Leerssen <scott@leerssen.com>

[-- Attachment #2: nfs-utils-1.0.1.mnt-root-orig.patch --]
[-- Type: text/x-patch, Size: 2169 bytes --]

diff -uNr nfs-utils-1.0.1/support/include/nfs/export.h nfs-utils-1.0.1.mnt-root-orig.patch/support/include/nfs/export.h
--- nfs-utils-1.0.1/support/include/nfs/export.h	Wed Feb 27 20:37:44 2002
+++ nfs-utils-1.0.1.mnt-root-orig.patch/support/include/nfs/export.h	Tue Jun 17 13:09:11 2003
@@ -24,6 +24,7 @@
 #define NFSEXP_NOSUBTREECHECK	0x0400
 #define NFSEXP_NOAUTHNLM	0x0800
 #define NFSEXP_FSID		0x2000
+#define NFSEXP_ROOTMNTORIG	0x4000
 #define NFSEXP_ALLFLAGS		0x3FFF
 
 #endif /* _NSF_EXPORT_H */
diff -uNr nfs-utils-1.0.1/support/nfs/exports.c nfs-utils-1.0.1.mnt-root-orig.patch/support/nfs/exports.c
--- nfs-utils-1.0.1/support/nfs/exports.c	Wed May 29 02:07:43 2002
+++ nfs-utils-1.0.1.mnt-root-orig.patch/support/nfs/exports.c	Tue Jun 17 13:12:15 2003
@@ -176,6 +176,8 @@
 		"no_" : "");
 	fprintf(fp, "%ssecure_locks,", (ep->e_flags & NFSEXP_NOAUTHNLM)?
 		"in" : "");
+	fprintf(fp, "%sroot_mnt_orig,", (ep->e_flags & NFSEXP_ROOTMNTORIG)?
+		"" : "no_");
 	if (ep->e_flags & NFSEXP_FSID) {
 		fprintf(fp, "fsid=%d,", ep->e_fsid);
 	}
@@ -346,6 +348,10 @@
 			ep->e_flags |= NFSEXP_ALLSQUASH;
 		else if (strcmp(opt, "no_all_squash") == 0)
 			ep->e_flags &= ~NFSEXP_ALLSQUASH;
+		else if (strcmp(opt, "root_mnt_orig") == 0)
+			ep->e_flags |= NFSEXP_ROOTMNTORIG;
+		else if (!strcmp(opt, "no_root_mnt_orig"))
+			ep->e_flags &= ~NFSEXP_ROOTMNTORIG;
 		else if (strcmp(opt, "subtree_check") == 0)
 			ep->e_flags &= ~NFSEXP_NOSUBTREECHECK;
 		else if (strcmp(opt, "no_subtree_check") == 0)
diff -uNr nfs-utils-1.0.1/utils/mountd/mountd.c nfs-utils-1.0.1.mnt-root-orig.patch/utils/mountd/mountd.c
--- nfs-utils-1.0.1/utils/mountd/mountd.c	Tue Jun 17 13:02:39 2003
+++ nfs-utils-1.0.1.mnt-root-orig.patch/utils/mountd/mountd.c	Tue Jun 17 13:14:42 2003
@@ -264,6 +264,10 @@
 	} else if (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) {
 		xlog(L_WARNING, "%s is not a directory or regular file", p);
 		*error = NFSERR_NOTDIR;
+	} else if ((((S_IRUSR|S_IRGRP|S_IROTH) & stb.st_mode) == 0) &&
+			((exp->m_export.e_flags & NFSEXP_ROOTMNTORIG) == 0)) {
+		xlog(L_WARNING, "%s not readable", p);
+		*error = NFSERR_ACCES;
 	} else {
 		struct nfs_fh_len  *fh;
 

^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: nfs root directory security
@ 2003-06-18 15:27 Heflin, Roger A.
  2003-06-18 15:59 ` Scott Leerssen
  0 siblings, 1 reply; 13+ messages in thread
From: Heflin, Roger A. @ 2003-06-18 15:27 UTC (permalink / raw)
  To: Scott Leerssen, Bogdan Costescu; +Cc: Neil Brown, nfs

Scott,

If you really want to be scared, try=20
"showmount -a servername"
This will tell the server to list the clients and what filesystems they =
have
mounted.  And unguessable becomes a non-issue, and anyone can grab =
anyone
elses data since they know exactly what partition to mount.


		Roger

> -----Original Message-----
> From:	Scott Leerssen [SMTP:scott@leerssen.com]
> Sent:	Wednesday, June 18, 2003 9:28 AM
> To:	Bogdan Costescu
> Cc:	Neil Brown; nfs@lists.sourceforge.net
> Subject:	Re: [NFS] nfs root directory security
>=20
> I agree with everything you say here, and in a controlled and fairly
> unchanging environment with clients you trust, exporting to specific
> clients is a perfectly acceptable solution.  All I'm suggesting is
> adding an extra "layer of the onion" by restricting the ability to =
mount
> read-restricted directories.  It gives us the ability to create
> mountable filesystems for each server in a path that can not be
> traversed by mounting higher level directories.
>=20
> Imagine if the B and C paths of /A/B/C/root are cryptographically
> generated names, and that C is different for every mount point, B is
> different for every "repository", and A is simply an anchor in the =
root
> of my NAS.  I can export my clients root filesystems as:
>=20
>    /A 192.168.100.0/255.255.255.0(rw,no_root_squash,...)
>=20
> If B and C are unmountable and unguessable (without a lot of failed =
and
> obvious nfs mount attempts), I don't have to worry about anyone but =
the
> intended client mounting its root filesystem (assuming the network is
> safe from sniffing DHCP and mount requests).  Plus, I don't have to =
have
> an entry for every single client.  I could, and that would buy me an
> added bit of assurance, but I don't need one so it's much easier to
> maintain hundreds of mount points.
>=20
> Of course, there's a lot more to securing an NFS environment such as
> this, particularly when you can't trust the clients to behave.  This
> tweak just eases the burden of managing exports for hundreds (or
> thousands) of clients on as many NAS as you can imagine.  The burden =
is
> shifted to managing unreadable pathnames in the management software...
> (sigh).
>=20
> That's about all I have to add on this... feel free to use the patch =
or,
> if you haven't already, delete it from your inbox.
>=20
> --=20
> Scott Leerssen <scott@leerssen.com>
>=20
>=20
>=20
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting =
Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly =
Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> NFS maillist  -  NFS@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nfs


-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: nfs root directory security
@ 2003-06-18 15:34 Heflin, Roger A.
  0 siblings, 0 replies; 13+ messages in thread
From: Heflin, Roger A. @ 2003-06-18 15:34 UTC (permalink / raw)
  To: Scott Leerssen, Bogdan Costescu; +Cc: Neil Brown, nfs



And Scott, you have the DHCP table, write a simple script
to take the info from the DHCP table and generate a proper
exports file based on that info.=20

You aren't doing two separate sets of the same information
separately?   We usually have a original set of files with info
in them (be that our own format, or the DHCP entries, or something
else), and then have scripts to generate the system files,
that would be used from that info, such as the DHCP and exports
entries, so the correct information is only in one place and=20
all others are derivitavies of that original source, this also reduces
mistakes where you are manually adjusting the several sources
and fail to keep everything consistant.

				Roger


-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2003-06-18 21:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-17 22:28 nfs root directory security Scott Leerssen
2003-06-17 23:36 ` Neil Brown
2003-06-18  2:54   ` Scott Leerssen
2003-06-18  3:47     ` Neil Brown
2003-06-18  3:38       ` Scott Leerssen
2003-06-18  9:30       ` Bogdan Costescu
2003-06-18 12:36         ` Scott Leerssen
2003-06-18 13:55           ` Bogdan Costescu
2003-06-18 14:27             ` Scott Leerssen
2003-06-18 21:16               ` Frank Cusack
  -- strict thread matches above, loose matches on Subject: below --
2003-06-18 15:27 Heflin, Roger A.
2003-06-18 15:59 ` Scott Leerssen
2003-06-18 15:34 Heflin, Roger A.

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.