Skip to content

Commit 91f269e

Browse files
committed
Python: Remove unused django sinks
This would find instances of `thing = MyThing.objects.get(field=userinput)`, and what seems to be a query that wants to match on `thing = MyThing(); thing.field=userinput`. Both are not vulnerable to user-input, due to the build-in escaping by django. The DjangoModelFieldWrite actually matches on `MyThing.field=userinput` and not `thing.field=userinput`. I suspect this to be a mistake. Matching on `thing.field=userinput`, would require this CodeQL: attr.getObject(_).pointsTo().getClass() = model
1 parent 4713183 commit 91f269e

1 file changed

Lines changed: 0 additions & 27 deletions

File tree

  • python/ql/src/semmle/python/web/django

python/ql/src/semmle/python/web/django/Model.qll

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,6 @@ class DjangoModelObjects extends TaintSource {
5454
override string toString() { result = "django.db.models.Model.objects" }
5555
}
5656

57-
/** A write to a field of a django model, which is a vulnerable to external data. */
58-
class DjangoModelFieldWrite extends SqlInjectionSink {
59-
DjangoModelFieldWrite() {
60-
exists(AttrNode attr, DjangoModel model |
61-
this = attr and attr.isStore() and attr.getObject(_).pointsTo(model)
62-
)
63-
}
64-
65-
override predicate sinks(TaintKind kind) { kind instanceof ExternalStringKind }
66-
67-
override string toString() { result = "django model field write" }
68-
}
69-
70-
/** A direct reference to a django model object, which is vulnerable to external data. */
71-
class DjangoModelDirectObjectReference extends TaintSink {
72-
DjangoModelDirectObjectReference() {
73-
exists(CallNode objects_get_call, ControlFlowNode objects | this = objects_get_call.getAnArg() |
74-
objects_get_call.getFunction().(AttrNode).getObject("get") = objects and
75-
any(DjangoDbTableObjects objs).taints(objects)
76-
)
77-
}
78-
79-
override predicate sinks(TaintKind kind) { kind instanceof ExternalStringKind }
80-
81-
override string toString() { result = "django model object reference" }
82-
}
83-
8457
/**
8558
* A call to the `raw` method on a django model. This allows a raw SQL query
8659
* to be sent to the database, which is a security risk.

0 commit comments

Comments
 (0)