Repository navigation
feat: report attacker input reaching eval and exec as code injection - #153
Merged
Merged
Conversation
eval and exec were CODE sinks with no rule reporting their flows, so the only finding was dangerous-eval, whatever the call ran. code-injection reports the calls attacker input reaches, with the refutation verdicts, and the sinks now read the code argument only: the globals and locals are data. The regression corpus gains three reviewed true positives.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #152.
evalandexecwereCODEsinks, yet no rule reportedCODEflows. The only finding came fromdangerous-eval, which reports every call whatever it runs, soeval(request.args["expr"])looked the same aseval("1 + 1").What changes
code-injectionis aTaintDetectorof theCODEkind, likecommand-injection(severity HIGH). It reports attacker input reaching aCODEsink, with the usual refutation verdicts, and through project functions too (through,sink_line).evalandexecsinks ofpython-stdlib-modelsnow read their first argument only, the code. Attacker data in theglobalsorlocalsdictionaries is data, not code, e.g.eval('x + 1', {'x': input()}). No rule reportedCODEbefore, so no earlier result changes.dangerous-evalis unchanged. It still reports every call toevalorexec, and the rules table says how the two relate.CODEsinks, and those only produce findings with this rule.Regression corpus
Three new findings and none removed. I reviewed each one against the source, and all three are true positives:
introduction/mitre.py:218,mitre_lab_25_apieval(request.POST.get('expression'))introduction/views.py:460,cmd_lab2eval(request.POST.get('val'))app.py:71,code_injectioneval(request.args["expression"])The first two are guarded only by tests on
request.methodoris_authenticated, which do not examine the value. Their verdict is thereforevulnerability.Tests
tests/test_code_injection.py:eval,exec,exec(compile(...)), and code built by concatenation are reported;globalsorlocals, andast.literal_evalare not;dangerous-evalstays next tocode-injection;build, so the first CI run caught the count it still held; it now runs locally too.