Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e933ba2

Browse files
committed
Python: Add basic support for stdlib cookie objects.
1 parent b8b4216 commit e933ba2

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

python/ql/src/semmle/python/web/Http.qll

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,36 @@ class WsgiEnvironment extends TaintKind {
5656

5757
}
5858

59+
/** A standard morsel object from a HTTP request, a value in a cookie,
60+
* typically an instance of `http.cookies.Morsel` */
61+
class UntrustedMorsel extends TaintKind {
62+
63+
UntrustedMorsel() {
64+
this = "http.Morsel"
65+
}
66+
67+
68+
override TaintKind getTaintOfAttribute(string name) {
69+
result instanceof ExternalStringKind and
70+
(
71+
name = "value"
72+
)
73+
}
74+
75+
}
76+
77+
/** A standard cookie object from a HTTP request, typically an instance of `http.cookies.SimpleCookie` */
78+
class UntrustedCookie extends TaintKind {
79+
80+
UntrustedCookie() {
81+
this = "http.Cookie"
82+
}
83+
84+
override TaintKind getTaintForFlowStep(ControlFlowNode fromnode, ControlFlowNode tonode) {
85+
tonode.(SubscriptNode).getValue() = fromnode and
86+
result instanceof UntrustedMorsel
87+
}
88+
89+
}
90+
5991

0 commit comments

Comments
 (0)