remove the "send(..)" and similar from unsafe-code-construction

This commit is contained in:
erik-krogh
2022-10-17 21:00:59 +02:00
parent f1668801d3
commit e7c6571f52
2 changed files with 6 additions and 1 deletions

View File

@@ -47,7 +47,8 @@ module UnsafeCodeConstruction {
TypeTracker::TypeBackTracker t, Concepts::CodeExecution codeExec
) {
t.start() and
result = codeExec.getCode().getALocalSource()
result = codeExec.getCode().getALocalSource() and
codeExec.runsArbitraryCode() // methods like `Object.send` is benign here, because of the string-construction the attacker cannot control the entire method name
or
exists(TypeTracker::TypeBackTracker t2 |
result = getANodeExecutedAsCode(t2, codeExec).backtrack(t2, t)

View File

@@ -16,4 +16,8 @@ class Foobar
def indirect_eval(x)
eval(x) # OK - no construction.
end
def send_stuff(x)
foo.send("foo_#{x}") # OK - attacker cannot control entire string.
end
end