# Insecure word writable dir?

**URL:** <https://www.ruby-forum.com/t/insecure-word-writable-dir/67130>\
**Category:** Ruby\
**Created:** [August 31, 2006, 10:19pm UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130 "2006-08-31T22:19:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [August 31, 2006, 10:19pm UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/1 "2006-08-31T22:19:01Z")

</div>

When I exec another program from inside Ruby, I get this warning:  
“warning: Insecure world writable dir /tmp, mode 041777”

Here’s /tmp  
drwxrwxrwt 17 root root 4096 Aug 31 13:16 /tmp/

Any ideas? It’s sort of annoying. I thought /tmp had to be world  
writable.

Joe

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [August 31, 2006, 10:33pm UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/2 "2006-08-31T22:33:06Z")

</div>

On Fri, 1 Sep 2006, Joe Van D. wrote:

> When I exec another program from inside Ruby, I get this warning:  
> “warning: Insecure world writable dir /tmp, mode 041777”
> 
> Here’s /tmp  
> drwxrwxrwt 17 root root 4096 Aug 31 13:16 /tmp/
> 
> Any ideas? It’s sort of annoying. I thought /tmp had to be world writable.
> 
> Joe

it’s very annoying.

$VERBOSE=nil

-a

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 1, 2006, 3:19am UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/3 "2006-09-01T03:19:34Z")

</div>

Hi,

In message “Re: Insecure word writable dir?”  
on Fri, 1 Sep 2006 05:18:32 +0900, “Joe Van D.”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|When I exec another program from inside Ruby, I get this warning:  
|“warning: Insecure world writable dir /tmp, mode 041777”  
|  
|Here’s /tmp  
|drwxrwxrwt 17 root root 4096 Aug 31 13:16 /tmp/  
|  
|Any ideas? It’s sort of annoying. I thought /tmp had to be world writable.

That means you have world writable directory in your load path ($PATH)  
when you call external program (probably by using “system”). If you  
know what you are doing, you can shut the warning up by

$VERBOSE=nil

as Ara told in [ruby-talk:211832].

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 1, 2006, 7:12am UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/4 "2006-09-01T07:12:01Z")

</div>

On Aug 31, 2006, at 6:17 PM, Yukihiro M. wrote:

> |Any ideas? It’s sort of annoying. I thought /tmp had to be world  
> writable.
> 
> That means you have world writable directory in your load path ($PATH)  
> when you call external program (probably by using “system”). If you  
> know what you are doing, you can shut the warning up by
> 
> $VERBOSE=nil
> 
> as Ara told in [ruby-talk:211832].

# Index: file.c

RCS file: /src/ruby/file.c,v  
retrieving revision 1.246  
diff -p -u -r1.246 file.c  
— file.c 31 Aug 2006 11:24:44 -0000 1.246  
+++ file.c 1 Sep 2006 05:09:38 -0000  
@@ -4073,7 +4073,7 @@ path\_check\_0(VALUE path, int loadpath)  
&& (loadpath || !(st.st\_mode & S\_ISVTX))  
#endif  
&& !access(p0, W\_OK)) {

- 

```
      rb_warn("Insecure world writable dir %s, mode 0%o", p0,

```

st.st\_mode);

- 

```
      rb_warn("Insecure world writable dir %s, mode 0%o in

```

$LOAD\_PATH", p0, st.st\_mode);  
if (p) \*p = ‘/’;  
return 0;  
}

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 1, 2006, 11:39am UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/5 "2006-09-01T11:39:18Z")

</div>

Hi,

In message “Re: Insecure word writable dir?”  
on Fri, 1 Sep 2006 14:11:45 +0900, Eric H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
writes:

|- rb\_warn(“Insecure world writable dir %s, mode 0%o”, p0, st.st\_mode);  
|  
|+ rb\_warn(“Insecure world writable dir %s, mode 0%o in $LOAD\_PATH”, p0, st.st\_mode);

It’s better, but this warning can be caused by both $PATH and  
$LOAD\_PATH, and currently has no clue to distinguish in this function.

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 2, 2006, 8:56am UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/6 "2006-09-02T08:56:01Z")

</div>

Hi,

At Fri, 1 Sep 2006 17:15:49 +0900,  
Yukihiro M. wrote in [ruby-talk:211948]:

> It’s better, but this warning can be caused by both $PATH and  
> $LOAD\_PATH, and currently has no clue to distinguish in this function.

I guess fpath\_check() to be check for LOAD\_PATH but not for  
PATH. Though I’ not sure rb\_loadpath\_check() is really  
necessary, when the required file is found in safe path.

# Index: file.c

RCS file: /cvs/ruby/src/ruby/file.c,v  
retrieving revision 1.246  
diff -p -u -2 -r1.246 file.c  
— file.c 31 Aug 2006 11:24:44 -0000 1.246  
+++ file.c 2 Sep 2006 06:51:28 -0000  
@@ -4074,5 +4074,6 @@ path\_check\_0(VALUE path, int loadpath)  
#endif  
&& !access(p0, W\_OK)) {

- 

```
  rb_warn("Insecure world writable dir %s, mode 0%o", p0, 

```

st.st\_mode);

- 

```
  rb_warn("Insecure world writable dir %s, mode 0%o in %s",

```

- 

```
      p0, st.st_mode, loadpath ? "$LOAD_PATH" : "PATH");
  if (p) *p = '/';
  return 0;

```

@@ -4091,5 +4092,5 @@ fpath\_check(const char \*path)  
{  
#ifndef DOSISH

- return path\_check\_0(rb\_str\_new2(path), Qfalse);

- return path\_check\_0(rb\_str\_new2(path), Qtrue);  
#else  
return 1;  
@@ -4097,6 +4098,6 @@ fpath\_check(const char \*path)  
}

-int  
-rb\_path\_check(const char \*path)  
+static int  
+rb\_pathlist\_check(const char \*path, int loadpath)  
{  
#ifndef DOSISH  
@@ -4112,5 +4113,5 @@ rb\_path\_check(const char \*path)

```
 for (;;) {

```

- if (!path\_check\_0(rb\_str\_new(p0, p - p0), Qtrue)) {

- if (!path\_check\_0(rb\_str\_new(p0, p - p0), loadpath)) {  
return 0; /\* not safe \*/  
}  
@@ -4124,4 +4125,16 @@ rb\_path\_check(const char \*path)  
}

+int  
+rb\_path\_check(const char \*path)  
+{

- return rb\_pathlist\_check(path, Qfalse);  
+}
- 

+int  
+rb\_loadpath\_check(const char \*path)  
+{

- return rb\_pathlist\_check(path, Qtrue);  
+}
- 

#if defined( **MACOS** ) || defined(riscos)  
static int  
@@ -4203,6 +4216,8 @@ rb\_find\_file(VALUE path)

```
 if (f[0] == '~') {

```

- volatile VALUE prevent\_from\_gc = path;  
path = rb\_file\_expand\_path(path, Qnil);  
if (rb\_safe\_level() \>= 1 && OBJ\_TAINTED(path)) {
- 

```
  (void)prevent_from_gc;
  rb_raise(rb_eSecurityError, "loading from unsafe path %s", f);

```

}  
@@ -4249,7 +4264,9 @@ rb\_find\_file(VALUE path)  
else {  
lpath = RSTRING\_PTR(tmp);

- 

```
  if (rb_safe_level() >= 1 && !rb_path_check(lpath)) {

```

+#if 0

- 

```
  if (rb_safe_level() >= 1 && !rb_loadpath_check(lpath)) {
  rb_raise(rb_eSecurityError, "loading from unsafe path %s", lpath);
  }

```

# +#endif } } Index: intern.h

RCS file: /cvs/ruby/src/ruby/intern.h,v  
retrieving revision 1.199  
diff -p -u -2 -r1.199 intern.h  
— intern.h 31 Aug 2006 08:24:36 -0000 1.199  
+++ intern.h 2 Sep 2006 06:48:03 -0000  
@@ -326,4 +326,5 @@ VALUE rb\_hash\_delete\_if(VALUE);  
VALUE rb\_hash\_delete(VALUE,VALUE);  
int rb\_path\_check(const char\*);  
+int rb\_loadpath\_check(const char\*);  
int rb\_env\_path\_tainted(void);  
/\* io.c \*/

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 6, 2006, 10:21pm UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/7 "2006-09-06T22:21:01Z")

</div>

On Thu, 7 Sep 2006, Ryan D. wrote:

> said, on my mac mini, where all user directories are on a separate disk, I  
> the warning is irrelevant to the actual code being executed, my pwd, or much  
> of anything else. 😕
> 
> $VERBOSE is valuable, very valuable… could we perhaps move this warning to  
> $DEBUG or only if $SAFE is set or something?

i second that. it’s the only reason i don’t use $VERBOSE too.

-a

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 7, 2006, 1:09am UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/8 "2006-09-07T01:09:20Z")

</div>

Hi,

In message “Re: Insecure word writable dir?”  
on Thu, 7 Sep 2006 05:18:34 +0900, removed\_email\_address@domain.invalid writes:

|\> $VERBOSE is valuable, very valuable… could we perhaps move this warning to  
|\> $DEBUG or only if $SAFE is set or something?  
|  
|i second that. it’s the only reason i don’t use $VERBOSE too.

We’ve changed the condition. World writable parent directories would  
not cause warnings if they have sticky bits set. I am not sure if it  
works on Windows as well.

```
						matz.
```

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 6, 2006, 9:20pm UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/9 "2006-09-06T21:20:55Z")

</div>

On Aug 31, 2006, at 6:17 PM, Yukihiro M. wrote:

> That means you have world writable directory in your load path ($PATH)  
> when you call external program (probably by using “system”). If you  
> know what you are doing, you can shut the warning up by
> 
> $VERBOSE=nil

I _like_ $VERBOSE and run it with everything but rails (because:  
ugh). That said, on my mac mini, where all user directories are on a  
separate disk, I get this warning constantly because of the  
automounter directory /Volumes

% pwd  
/Volumes/Users/ryan/  
% ls -lad /Volumes/  
drwxrwxrwt 6 root admin 204 Aug 27 20:44 /Volumes/  
% cd /tmp; ruby -we ‘`/bin/ls`’  
-e:1: warning: Insecure world writable dir /Volumes, mode 041777

this is because my PATH has /Volumes/Users/ryan/Bin but as you can  
see above, the warning is irrelevant to the actual code being  
executed, my pwd, or much of anything else. 😕

$VERBOSE is valuable, very valuable… could we perhaps move this  
warning to $DEBUG or only if $SAFE is set or something?

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 7, 2006, 9:58am UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/10 "2006-09-07T09:58:16Z")

</div>

Hi,

In message “Re: Insecure word writable dir?”  
on Thu, 7 Sep 2006 14:14:38 +0900, “Nobuyoshi N.”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|The check is disabled on Windows.  
|  
|I guess it should be disabled on Cygwin too.

Please commit.

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 7, 2006, 7:15am UTC](https://www.ruby-forum.com/t/insecure-word-writable-dir/67130/11 "2006-09-07T07:15:49Z")

</div>

Hi,

At Thu, 7 Sep 2006 08:08:29 +0900,  
Yukihiro M. wrote in [ruby-talk:213041]:

> We’ve changed the condition. World writable parent directories would  
> not cause warnings if they have sticky bits set. I am not sure if it  
> works on Windows as well.

The check is disabled on Windows.

I guess it should be disabled on Cygwin too.

# Index: file.c

RCS file: /home/K8052/cvs/ruby/file.c,v  
retrieving revision 1.248  
diff -U 2 -p -u -r1.248 file.c  
— file.c 4 Sep 2006 20:49:52 -0000 1.248  
+++ file.c 5 Sep 2006 08:43:05 -0000  
@@ -4045,5 +4045,13 @@ is\_absolute\_path(const char \*path)  
}

-#ifndef DOSISH  
+#ifndef ENABLE\_PATH\_CHECK  
+# if defined DOSISH || defined **CYGWIN**  
+# define ENABLE\_PATH\_CHECK 0  
+# else  
+# define ENABLE\_PATH\_CHECK 1  
+# endif  
+#endif  
+  
+#if ENABLE\_PATH\_CHECK  
static int  
path\_check\_0(VALUE path, int execpath)  
@@ -4090,5 +4098,5 @@ static int  
fpath\_check(const char \*path)  
{  
-#ifndef DOSISH  
+#if ENABLE\_PATH\_CHECK  
return path\_check\_0(rb\_str\_new2(path), Qfalse);  
#else  
@@ -4100,5 +4108,5 @@ int  
rb\_path\_check(const char \*path)  
{  
-#ifndef DOSISH  
+#if ENABLE\_PATH\_CHECK  
const char \*p0, \*p, \*pend;  
const char sep = PATH\_SEP\_CHAR;
