Skip to content

Commit 7020e41

Browse files
committed
Python: Model BaseHTTPRequestHandler.rfile as file-like object
1 parent d388dd5 commit 7020e41

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

python/ql/src/semmle/python/frameworks/Stdlib.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,13 @@ private module StdlibPrivate {
10311031
}
10321032
}
10331033

1034+
/** A file-like object that originates from a `BaseHTTPRequestHandler` instance. */
1035+
private class BaseHTTPRequestHandlerFileLikeObjectInstances extends Stdlib::FileLikeObject::InstanceSource {
1036+
BaseHTTPRequestHandlerFileLikeObjectInstances() {
1037+
this.(DataFlow::AttrRead).accesses(instance(), "rfile")
1038+
}
1039+
}
1040+
10341041
/**
10351042
* The entry-point for handling a request with a `BaseHTTPRequestHandler` subclass.
10361043
*

python/ql/test/library-tests/frameworks/stdlib/http_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def taint_sources(self):
6868
bytes(self.headers), # $ tainted
6969

7070
self.rfile, # $ tainted
71-
self.rfile.read(), # $ MISSING: tainted
71+
self.rfile.read(), # $ tainted
7272
)
7373

7474
form = cgi.FieldStorage(

0 commit comments

Comments
 (0)