-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathReadingFromWorldWritableFile.ql
More file actions
26 lines (24 loc) · 1.04 KB
/
ReadingFromWorldWritableFile.ql
File metadata and controls
26 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* @name Reading from a world writable file
* @description Reading from a file which is set as world writable is dangerous because
* the file may be modified or removed by external actors.
* @kind problem
* @problem.severity error
* @security-severity 7.8
* @precision high
* @id java/world-writable-file-read
* @tags security
* external/cwe/cwe-732
*/
import java
import semmle.code.java.security.FileReadWrite
import semmle.code.java.security.FileWritable
from Variable fileVariable, FileReadExpr readFrom, SetFileWorldWritable setWorldWritable
where
// The file variable must be both read from and set to world writable. This is not flow-sensitive.
fileVariable.getAnAccess() = readFrom.getFileVarAccess() and
fileVariable.getAnAccess() = setWorldWritable.getFileVarAccess() and
// If the file variable is a parameter, the result should be reported in the caller.
not fileVariable instanceof Parameter
select setWorldWritable, "This sets a file is as world writable, but is read from $@.", readFrom,
"statement"