Skip to content

Commit bcfc28a

Browse files
committed
add sources to detect CVE completely
1 parent 7aa002f commit bcfc28a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

python/ql/src/experimental/Security/CWE-409/DecompressionBombs.ql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ module ZipFile {
137137
* zipfile.ZipFile()
138138
* ```
139139
*/
140-
private API::Node zipFileClass() {
140+
API::Node zipFileClass() {
141141
result =
142142
[
143143
API::moduleImport("zipfile").getMember("ZipFile"),
@@ -253,7 +253,8 @@ module ZipFile {
253253
*/
254254
predicate isAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
255255
exists(API::Node zipFileInstance | zipFileInstance = zipFileClass() |
256-
nodeFrom = zipFileInstance.getACall().getParameter(0, "file").asSink() and
256+
nodeFrom =
257+
[zipFileInstance.getACall().getParameter(0, "file").asSink(), zipFileInstance.getACall()] and
257258
nodeTo =
258259
[
259260
sink(zipFileInstance).getACall(),
@@ -317,7 +318,8 @@ module TarFile {
317318

318319
predicate isAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
319320
exists(API::Node tarfileInstance | tarfileInstance = tarfileInstance() |
320-
nodeFrom = tarfileInstance.getACall().getParameter(0, "name").asSink() and
321+
nodeFrom =
322+
[tarfileInstance.getACall().getParameter(0, "name").asSink(), tarfileInstance.getACall()] and
321323
nodeTo =
322324
tarfileInstance.getReturn().getMember(["extractall", "extract", "extractfile"]).getACall()
323325
)
@@ -497,6 +499,10 @@ module BombsConfig implements DataFlow::ConfigSig {
497499
)
498500
or
499501
source instanceof FileAndFormRemoteFlowSource::FastAPI
502+
or
503+
source = TarFile::tarfileInstance().getACall()
504+
or
505+
source = ZipFile::zipFileClass().getACall()
500506
}
501507

502508
predicate isSink(DataFlow::Node sink) {

0 commit comments

Comments
 (0)