Repository navigation
feat: reach advisory entry points marked read through attribute reads - #125
Merged
Merged
Conversation
Merged
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 #111.
Some advisory entry points are attributes whose getter runs the vulnerable code. Werkzeug parses a multipart body when
request.form,request.files,request.dataorrequest.valuesis read (CVE-2023-25577). Until now,reachable-vulnerabilityonly looked at call sites. A project that readsrequest.form["name"]or runsfor key in request.fileswas never reported, and curated data could only list the call forms it knew of (request.form.get(...)).Change
"read": true, which is validated as a boolean.AdvisoryEntryPoint.readdefaults to false, so existing files mean what they meant. I named itreadinstead ofpropertyto describe how the entry point is reached, and to avoid shadowing the builtin.CallGraph.reads(function)returns, asSymbolReadrecords, the symbols a function reads, whether it calls them or not. A read is aSymbolorGetAttrinstruction whose value denotes a symbol, recorded where the function first reads it. This covers annotated parameters (request: Request) and inherited attributes, because it reuses the call graph's own symbol map.read, or of an attribute of one, reaches it.request.form.getreadsrequest.form, and the lowering folds that chain into a singlepython.flask.request.form.getsymbol, so the plugin also checks every prefix of the read symbol. It reports one finding per function and entry point, where the function first reads it. A read entry point that is also called is reported once, through the read. An entry point withoutreadis still reached by a call only.Out of scope
reachable. Whether the reading route is exposed is the job ofexposure-prioritization.readin a separate PR on that repository.Cost
On healthchecks, the largest corpus project, the cached reads take 5.0 MB of a 22.7 MB cache (20,633 reads), next to 6.2 MB for call sites. Every read is kept. Filtering, for example leaving out builtins, would be a heuristic that makes the
readsAPI less general.Verification
pytest(the default selection): 983 passed.pytest -m regressionunder Python 3.12, the CI interpreter: 19 passed, with every snapshot unchanged. No bundled advisory marks an entry pointread.ruff check src testsandmypyare clean.readflag, and not rebuilding reads from the cache.