File tree Expand file tree Collapse file tree 2 files changed +17
-23
lines changed
Expand file tree Collapse file tree 2 files changed +17
-23
lines changed Original file line number Diff line number Diff line change @@ -38,21 +38,25 @@ private class YamlParseStep extends AdditionalTaintStep {
3838 )
3939 )
4040 or
41- exists ( API:: Node yamlParserMethod |
41+ exists ( API:: Node parseSuccessors | parseSuccessors = yamlParseChildNodeAccess ( _ ) |
4242 succ =
4343 [
44- yamlParserMethod .getASuccessor * ( ) .getMethod ( "to_ruby" ) .getReturn ( ) .asSource ( ) ,
45- yamlParserMethod
46- .getASuccessor * ( )
47- .getMethod ( "to_ruby" )
48- .getReturn ( )
49- .getAnElement ( )
50- .asSource ( )
44+ parseSuccessors .getMethod ( "to_ruby" ) .getReturn ( ) .asSource ( ) ,
45+ parseSuccessors .getMethod ( "to_ruby" ) .getReturn ( ) .getAnElement ( ) .asSource ( )
5146 ] and
52- yamlParserMethod = yamlNode ( ) .getMethod ( [ "parse" , "parse_stream" , "parse_file" ] ) and
53- pred = yamlParserMethod .getReturn ( ) .asSource ( )
47+ pred = parseSuccessors .asSource ( )
5448 )
5549 }
5650}
5751
52+ API:: Node yamlParseChildNodeAccess ( API:: Node source ) {
53+ source = yamlNode ( ) .getMethod ( [ "parse" , "parse_stream" ] ) .getReturn ( ) and source = result
54+ or
55+ result = yamlParseChildNodeAccess ( source ) .getMethod ( _) .getReturn ( )
56+ or
57+ result = yamlParseChildNodeAccess ( source ) .getMethod ( _) .getBlock ( ) .getParameter ( _)
58+ or
59+ result = yamlParseChildNodeAccess ( source ) .getAnElement ( )
60+ }
61+
5862private API:: Node yamlNode ( ) { result = API:: getTopLevelMember ( [ "YAML" , "Psych" ] ) }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ private import codeql.ruby.dataflow.RemoteFlowSources
1111private import codeql.ruby.frameworks.ActiveJob
1212private import codeql.ruby.frameworks.core.Module
1313private import codeql.ruby.frameworks.core.Kernel
14+ private import codeql.ruby.frameworks.Yaml
1415
1516module UnsafeDeserialization {
1617 /**
@@ -103,19 +104,8 @@ module UnsafeDeserialization {
103104 YamlParseArgument ( ) {
104105 this =
105106 [
106- yamlNode ( )
107- .getMethod ( [ "parse" , "parse_stream" , "parse_file" ] )
108- .getASuccessor * ( )
109- .getMethod ( "to_ruby" )
110- .getReturn ( )
111- .asSource ( ) ,
112- yamlNode ( )
113- .getMethod ( [ "parse" , "parse_stream" , "parse_file" ] )
114- .getASuccessor * ( )
115- .getMethod ( "to_ruby" )
116- .getReturn ( )
117- .getAnElement ( )
118- .asSource ( )
107+ yamlParseChildNodeAccess ( _) .getMethod ( "to_ruby" ) .getReturn ( ) .asSource ( ) ,
108+ yamlParseChildNodeAccess ( _) .getMethod ( "to_ruby" ) .getReturn ( ) .getAnElement ( ) .asSource ( )
119109 ]
120110 }
121111 }
You can’t perform that action at this time.
0 commit comments