a0650d
diff --git a/jinja2/bccache.py b/jinja2/bccache.py
a0650d
index 09ff845..c31a905 100644
a0650d
--- a/jinja2/bccache.py
a0650d
+++ b/jinja2/bccache.py
a0650d
@@ -16,6 +16,7 @@
a0650d
 """
a0650d
 from os import path, listdir
a0650d
 import os
a0650d
+import stat
a0650d
 import sys
a0650d
 import errno
a0650d
 import marshal
a0650d
@@ -230,6 +231,14 @@ class FileSystemBytecodeCache(BytecodeCache):
a0650d
             if e.errno != errno.EEXIST:
a0650d
                 raise
a0650d
 
a0650d
+        if os.lstat(actual_dir).st_uid != os.getuid():
a0650d
+            raise RuntimeError('Someone else owns temp directory with your '
a0650d
+                               'uid. You need to explicitly provide another.')
a0650d
+
a0650d
+        if stat.S_IMODE(os.lstat(actual_dir).st_mode) != 448:
a0650d
+            raise RuntimeError('Bad permission flags on temp directory, '
a0650d
+                               'shoud be 0700. You need to fix this.')
a0650d
+
a0650d
         return actual_dir
a0650d
 
a0650d
     def _get_cache_filename(self, bucket):