Skip to content

nfs export symlink vulnerability fix (duplicate(ish))

Christopher Bii linux-nfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5nfsd_path.h - nfsd_path.c: - Configured export rootdir must now be an absolute path - Rootdir is into a global variable what will also be used to retrieve it later on - nfsd_path_nfsd_rootdir(void) is simplified with nfsd_path_rootdir which returns the global var rather than reprobing config for rootdir entrysupport/export/export.c support/include/nfsd_path.h support/misc/nfsd_path.c+27 -420 replies
2/5nfsd_path.c: - Simplification of nfsd_path_strip_root(char*)support/misc/nfsd_path.c+4 -120 replies
3/5nfsd_path.h - nfsd_path.c: - nfsd_path_prepend_dir(const char*, const char*) -> nfsd_path_prepend_root(const char*)support/export/export.c support/include/nfsd_path.h support/misc/nfsd_path.c+15 -300 replies
4/5NFS export symlink vulnerability fix - Replaced dangerous use of realpath within support/nfs/export.c with nfsd_realpath variant that is executed within the chrooted thread rather than main thread. - Implemented nfsd_path.h methods to work securely within chrooted thread using nfsd_run_task() helpersupport/include/nfsd_path.h support/misc/nfsd_path.c support/nfs/exports.c+80 -1830 replies
5/5support/nfs/exports.c - Small changessupport/nfs/exports.c+27 -210 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] nfs export symlink vulnerability fix (duplicate(ish))

Hello,

It is hinted in the configuration files that an attacker could gain access to arbitrary folders by guessing symlink paths that match exported dirs, but this is not the case. They can get access to the root export with certainty by simply symlinking to "../../../../../../../", which will always return "/".

This is due to realpath() being called in the main thread which isn't chrooted, concatenating the result with the export root to create the export entry's final absolute path which the kernel then exports.

PS: I already sent this patch to the mailing list about the same subject but it was poorly formatted. Changes were merged into a single commit. I have broken it up into smaller commits and made the patch into a single thread. Pardon the mistake, first contribution.

Thanks

Christopher Bii (5):
nfsd_path.h - nfsd_path.c: - Configured export rootdir must now be an
absolute path - Rootdir is into a global variable what will also be
used to retrieve it later on - nfsd_path_nfsd_rootdir(void) is
simplified with nfsd_path_rootdir which returns the global var
rather than reprobing config for rootdir entry
nfsd_path.c: - Simplification of nfsd_path_strip_root(char*) nfsd_path.h - nfsd_path.c: - nfsd_path_prepend_dir(const char*, const

    char*) -> nfsd_path_prepend_root(const char*)

NFS export symlink vulnerability fix - Replaced dangerous use of
realpath within support/nfs/export.c with nfsd_realpath variant
that is executed within the chrooted thread rather than main
thread. - Implemented nfsd_path.h methods to work securely within
chrooted thread using nfsd_run_task() helper
support/nfs/exports.c - Small changes

 support/export/export.c     |  17 +-
 support/include/nfsd_path.h |   9 +-
 support/misc/nfsd_path.c    | 362 ++++++++++++------------------------
 support/nfs/exports.c       |  49 ++---
 4 files changed, 151 insertions(+), 286 deletions(-)
Signature · 1 line
2.47.1