Repository navigation
feat(code-injection): report attributes chosen by input and then called - #257
Merged
Merged
Conversation
Part of #240: getattr(obj, name)(...), one finding per invocation.
luigi/server.py:101 calls getattr(self._scheduler, method) with the route's method; RPC_METHODS is a module-level registry, so the guard proves nothing and the flow is a hotspot.
…e calls of call results A check proving the name where getattr selects holds past a join; a flow is refuted when its selection or its invocation cannot run, and a summary keeps an invocation only when both can. Calling the result of a call, or an item of it, now calls its __call__ instead of the symbol it comes from, so its arguments are not read as the original call's. Part of #240.
…elected in an earlier iteration When the callable reaches its invocation across a loop's back edge, it was selected with an earlier instance of the name than the one a check at the invocation tests: only the checks where getattr selects prove it there. Part of #240.
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.
Part 2 of #240, second change:
getattr(obj, name)(...). With #256 (import path), this completes #240.Summary
Model:
Sink.requires_called_resultholds the kinds that apply only when the call's result is itself called.ModelTable.extendeddoes not widen a conditional kind.Sink.applying(invoked)gives the kinds that apply to the call itself or to one invocation of its result.getattris aCODEsink on its name (argument 1), withselects, that requires its result to be called.Summaries keep facts, independently of the models:
ExternalCall.invoked_atgives one record per invocation of an external call's result.locationstays the selecting call.invoked_at, which is copied unchanged along helper chains.ir.defuse.invocations, through copies and phis.The consuming engine filters:
TaintFlow.invoked_at). Checks between selection and invocation are therefore judged.known()applies the same split per record.Findings:
code-injectionreports a hotspot titledUntrusted attribute call, on modules and behind prefixes too, withselected_lineandinvoked_linein the metadata.getattrreceived to constants. A check on a name rebound since, or on a derived value, proves nothing.attrgetter/methodcaller/__getattribute__/vars(); checks inside helpers.Verification
New
tests/test_attribute_call_sinks.pyandtests/test_sink_called_result.py: 33 tests, covering:eval(x)(), and an extra plugin declaringgetattrunconditionally);No existing test changed apart from the luigi regression snapshot, in its own commit.
Mutation check: breaking the record key, the cache encoding, the merge or the kind split fails the new tests.
Full suite green, apart from the local
test_packagingmetadata issue.ruff checkandmypyclean.Regression: one new finding, a hotspot at
luigi/server.py:101:getattr(self._scheduler, method)(**arguments)with the route'smethod;RPC_METHODSis a module-level registry filled by a decorator, so it proves nothing (refutation: constant allowlists other than tuple and list literals are not recognised #239).No
getattrfinding on mitmproxy or healthchecks; cache size +2.3% and +1.7%.Closes #240