feat(checks): flag insecure deserialization introduced in a PR diff - #21
Merged
Conversation
Closes #2. scan_deserialization flags a deserialization sink an added line introduces, across Python (pickle, marshal, shelve, yaml.load without a safe Loader, yaml.unsafe_load), Java (ObjectInputStream / readObject), PHP (unserialize), Ruby (Marshal.load / YAML.load) and .NET (BinaryFormatter, NetDataContractSerializer, LosFormatter, ObjectStateFormatter). Advisory, never blocking, as the issue asks. Deserialization is an RCE surface, but whether the input is attacker-controlled cannot be decided from a diff hunk — a fixture loading its own artifact is routine. So this adds reviewer context and never decides mergeability, matching how arch.dynamic_exec treats eval/exec. Precision details: * added lines only, so a REMOVED sink (a fix) is not a finding * whole-line comments are skipped in all four comment styles — the mistake ci.pull_request_target made, where documenting a risk tripped the rule meant to catch it * yaml.load(..., Loader=SafeLoader/CSafeLoader/BaseLoader), yaml.safe_load and json.loads are not flagged; yaml.unsafe_load always is * one finding per added line (first matching sink wins) * sinks under tests/fixtures/testdata/examples/benchmarks report MEDIUM instead of HIGH 6 tests: all ten sinks across six languages, advisory/non-blocking, the four safe forms, comments in Python and Java, added-lines-only via a removal-only diff, and the test-path severity split.
26 tasks
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 #2.
scan_deserializationflags a deserialization sink that an added line introduces:pickle.load(s),marshal.load(s),shelve.open,yaml.loadwithout a safe Loader,yaml.unsafe_loadnew ObjectInputStream(...),.readObject()unserialize(Marshal.load,YAML.loadBinaryFormatter,NetDataContractSerializer,LosFormatter,ObjectStateFormatterAdvisory, never blocking
As the issue specifies. Deserialization is the shape of an RCE surface, but whether the input is attacker-controlled cannot be read off a diff hunk — a fixture loading its own cache artifact is routine. So this adds context for the reviewer and never decides mergeability, matching how
arch.dynamic_exectreatseval/exec.Precision
#,//,*,/*). This is deliberate: it's precisely the mistakeci.pull_request_targetmade, where documenting a risk tripped the rule meant to catch it (fix(checks): CI rules fired on YAML comments; tighten pull_request_target to the real trigger #18).yaml.load(..., Loader=SafeLoader),Loader=CSafeLoader,Loader=BaseLoader,yaml.safe_load,json.loads.yaml.unsafe_loadalways is.tests/,fixtures/,testdata/,examples/,benchmarks/) — still surfaced, weighted for what it is.Verification
37 tests pass,
ruffclean. 6 new tests: all ten sinks across six languages, advisory/non-blocking behaviour, the four safe forms, comments in both Python and Java styles, added-lines-only, and the test-path severity split.This was the last open code issue in this repo.