Skip to content

Commit 7142ddc

Browse files
committed
Python: add taint step for __traceback__
1 parent b36e0d0 commit 7142ddc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

python/ql/src/semmle/python/security/dataflow/StackTraceExposure.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import python
77
import semmle.python.dataflow.new.DataFlow
88
import semmle.python.dataflow.new.TaintTracking
99
import semmle.python.Concepts
10+
import semmle.python.dataflow.new.internal.Attributes
1011
private import ExceptionInfo
1112

1213
/**
@@ -20,4 +21,11 @@ class StackTraceExposureConfiguration extends TaintTracking::Configuration {
2021
override predicate isSink(DataFlow::Node sink) {
2122
sink = any(HTTP::Server::HttpResponse response).getBody()
2223
}
24+
25+
override predicate isAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
26+
exists(AttrRead attr | attr.getAttributeName() = "__traceback__" |
27+
nodeFrom = attr.getObject() and
28+
nodeTo = attr
29+
)
30+
}
2331
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
edges
22
| test.py:23:25:23:25 | SSA variable e | test.py:24:16:24:16 | ControlFlowNode for e |
3+
| test.py:31:25:31:25 | SSA variable e | test.py:32:16:32:30 | ControlFlowNode for Attribute |
34
| test.py:49:15:49:36 | ControlFlowNode for Attribute() | test.py:50:29:50:31 | ControlFlowNode for err |
45
| test.py:50:29:50:31 | ControlFlowNode for err | test.py:50:16:50:32 | ControlFlowNode for format_error() |
56
nodes
67
| test.py:16:16:16:37 | ControlFlowNode for Attribute() | semmle.label | ControlFlowNode for Attribute() |
78
| test.py:23:25:23:25 | SSA variable e | semmle.label | SSA variable e |
89
| test.py:24:16:24:16 | ControlFlowNode for e | semmle.label | ControlFlowNode for e |
10+
| test.py:31:25:31:25 | SSA variable e | semmle.label | SSA variable e |
11+
| test.py:32:16:32:30 | ControlFlowNode for Attribute | semmle.label | ControlFlowNode for Attribute |
912
| test.py:49:15:49:36 | ControlFlowNode for Attribute() | semmle.label | ControlFlowNode for Attribute() |
1013
| test.py:50:16:50:32 | ControlFlowNode for format_error() | semmle.label | ControlFlowNode for format_error() |
1114
| test.py:50:29:50:31 | ControlFlowNode for err | semmle.label | ControlFlowNode for err |
1215
#select
1316
| test.py:16:16:16:37 | ControlFlowNode for Attribute() | test.py:16:16:16:37 | ControlFlowNode for Attribute() | test.py:16:16:16:37 | ControlFlowNode for Attribute() | $@ may be exposed to an external user | test.py:16:16:16:37 | ControlFlowNode for Attribute() | Error information |
1417
| test.py:24:16:24:16 | ControlFlowNode for e | test.py:23:25:23:25 | SSA variable e | test.py:24:16:24:16 | ControlFlowNode for e | $@ may be exposed to an external user | test.py:23:25:23:25 | SSA variable e | Error information |
18+
| test.py:32:16:32:30 | ControlFlowNode for Attribute | test.py:31:25:31:25 | SSA variable e | test.py:32:16:32:30 | ControlFlowNode for Attribute | $@ may be exposed to an external user | test.py:31:25:31:25 | SSA variable e | Error information |
1519
| test.py:50:16:50:32 | ControlFlowNode for format_error() | test.py:49:15:49:36 | ControlFlowNode for Attribute() | test.py:50:16:50:32 | ControlFlowNode for format_error() | $@ may be exposed to an external user | test.py:49:15:49:36 | ControlFlowNode for Attribute() | Error information |

0 commit comments

Comments
 (0)