|
|
5ed7ec |
From: Chris Liddell <chris.liddell@artifex.com>
|
|
|
5ed7ec |
Date: Tue, 21 Aug 2018 19:17:51 +0000 (+0100)
|
|
|
5ed7ec |
Subject: Bug 699658: Fix handling of pre-SAFER opened files.
|
|
|
5ed7ec |
|
|
|
5ed7ec |
Bug 699658: Fix handling of pre-SAFER opened files.
|
|
|
5ed7ec |
|
|
|
5ed7ec |
Temp files opened for writing before SAFER is engaged are not subject to the
|
|
|
5ed7ec |
SAFER restrictions - that is handled by recording in a dictionary, and
|
|
|
5ed7ec |
checking that as part of the permissions checks.
|
|
|
5ed7ec |
|
|
|
5ed7ec |
By adding a custom error handler for invalidaccess, that allowed the filename
|
|
|
5ed7ec |
to be added to the dictionary (despite the attempted open throwing the error)
|
|
|
5ed7ec |
thus meaning subsequent accesses were erroneously permitted.
|
|
|
5ed7ec |
|
|
|
5ed7ec |
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=a054156d425b4dbdaaa9fda4b5f1182b27598c2b
|
|
|
5ed7ec |
---
|
|
|
5ed7ec |
|
|
|
5ed7ec |
diff -up a/Resource/Init/gs_init.ps.cve-2018-16539 b/Resource/Init/gs_init.ps
|
|
|
5ed7ec |
--- a/Resource/Init/gs_init.ps.cve-2018-16539 2018-11-14 16:34:23.268867657 +0100
|
|
|
5ed7ec |
+++ b/Resource/Init/gs_init.ps 2018-11-14 16:36:38.765552576 +0100
|
|
|
5ed7ec |
@@ -2015,6 +2015,19 @@ readonly def
|
|
|
5ed7ec |
concatstrings concatstrings .generate_dir_list_templates
|
|
|
5ed7ec |
} if
|
|
|
5ed7ec |
]
|
|
|
5ed7ec |
+ /PermitFileWriting [
|
|
|
5ed7ec |
+ currentuserparams /PermitFileWriting get aload pop
|
|
|
5ed7ec |
+ (TMPDIR) getenv not
|
|
|
5ed7ec |
+ {
|
|
|
5ed7ec |
+ (TEMP) getenv not
|
|
|
5ed7ec |
+ {
|
|
|
5ed7ec |
+ (TMP) getenv not
|
|
|
5ed7ec |
+ {
|
|
|
5ed7ec |
+ (/temp) (/tmp)
|
|
|
5ed7ec |
+ } if
|
|
|
5ed7ec |
+ } if
|
|
|
5ed7ec |
+ } if
|
|
|
5ed7ec |
+ ]
|
|
|
5ed7ec |
/LockFilePermissions //true
|
|
|
5ed7ec |
>> setuserparams
|
|
|
5ed7ec |
}
|
|
|
5ed7ec |
@@ -2062,7 +2075,9 @@ readonly def
|
|
|
5ed7ec |
% the file can be deleted later, even if SAFER is set.
|
|
|
5ed7ec |
/.tempfile {
|
|
|
5ed7ec |
.tempfile % filename file
|
|
|
5ed7ec |
- //SAFETY /tempfiles get 2 .argindex //true .forceput
|
|
|
5ed7ec |
+ //SAFETY /safe get not { % only add the filename if we're not yet safe
|
|
|
5ed7ec |
+ //SAFETY /tempfiles get 2 .argindex //true .forceput
|
|
|
5ed7ec |
+ } if
|
|
|
5ed7ec |
} .bind executeonly odef
|
|
|
5ed7ec |
|
|
|
5ed7ec |
% If we are running in SAFER mode, lock things down
|