Subject: Re: Symlink Check: editors/joe
To: Trevor Johnson <trevor@jpj.net>
From: Brian Seklecki <lavalamp@burghcom.com>
List: tech-pkg
Date: 02/13/2001 02:04:44
Yes but no generic source code patch is provided. Here is one a pieced
together from FreeBSD as well as Securityfocus.com :
This fixes the umask of DEADJOE as well as does sanity checking on whether
DEADJOE is a link or not. We should probably update our local pkgsrc.
$ diff -u b.c-orig b.c
--- b.c-orig Tue Feb 13 01:48:16 2001
+++ b.c Tue Feb 13 01:48:15 2001
@@ -21,6 +21,9 @@
#include <pwd.h>
#endif
#include <errno.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "config.h"
#include "blocks.h"
@@ -1990,7 +1993,19 @@
{
long tim=time(0);
B *b;
- FILE *f=fopen("DEADJOE","a");
+ mode_t mask=umask (077); /* no access to DEADJOE for others */
+ FILE *f;
+ struct stat sb;
+ if ((lstat("DEADJOE", &sb) == 0) && (((sb.st_mode & S_IFLNK) && (sb.st_uid
!= getuid())) || (sb.st_nlink > 1)))
+ {
+ printf("*** JOE was aborted ");
+ if (sig) printf("by signal %d, cannot save DEADJOE due to unsafe
symlink\n",sig);
+ else printf("because the terminal closed, cannot save DEADJOE due to
unsafe symlink\n");
+ if(sig) ttclsn();
+ _exit(1);
+ }
+ f=fopen("DEADJOE","a");
+ chmod("DEADJOE", S_IRUSR | S_IWUSR);
fprintf(f,"\n*** Modified files in JOE when it aborted on %s",ctime(&tim));
if(sig) fprintf(f,"*** JOE was aborted by signal %d\n",sig);
else fprintf(f,"*** JOE was aborted because the terminal closed\n");
--Brian
Trevor Johnson wrote:
> > Is anyone familiar with the BUGTRAQ discussions on a local vulnerability
> > in Joe 2.8 regarding improper sanity checking on DEADJOE?
>
> The problem is described in:
> http://www.wkit.com/include/eng/advisories/wsir0111.txt .
>
> > I'm looking at a patch (we won't go into the source >:} ) to correct:
>
> Credit for this patch should go to Kevin Day <toasty@dragondata.com>.
> --
> Trevor Johnson
> http://jpj.net/~trevor/gpgkey.txt