1- // Note that new active scripts will initially be disabled
2- // Right click the script in the Scripts tree and select "enable"
3-
41// This active scanner script checks for CVE-2019-5418
52
6- /**
7- * Scans a "node", i.e. an individual entry in the Sites Tree.
8- * The scanNode function will typically be called once for every page.
9- *
10- * @param as - the ActiveScan parent object that will do all the core interface tasks
11- * (i.e.: sending and receiving messages, providing access to Strength and Threshold settings,
12- * raising alerts, etc.). This is an ScriptsActiveScanner object.
13- * @param msg - the HTTP Message being scanned. This is an HttpMessage object.
14- */
15- function scanNode ( as , msg ) {
16- // Set some details we will need for alerts later
17- var alertRisk = 3 ;
18- var alertConfidence = 2 ;
19- var alertTitle = "CVE-2019-5418 - File Content Disclosure" ;
20- var alertDesc =
21- "The application seems to be subject to CVE-2019-5418. \
22- By sending a specially crafted request it was possible to have the target return \
23- data from the server file system." ;
24- var alertSolution =
25- "Upgrade to a version of Ruby/Rails where this issue is fixed. (See references for further details)." ;
26- var alertInfo =
27- "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-5418\nhttps://github.com/mpgn/CVE-2019-5418" ;
28- var cweId = 74 ; //Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
29- var wascId = 33 ; // Path Traversal
30- var url = msg . getRequestHeader ( ) . getURI ( ) . toString ( ) ;
3+ var ScanRuleMetadata = Java . type (
4+ "org.zaproxy.addon.commonlib.scanrules.ScanRuleMetadata"
5+ ) ;
6+ var CommonAlertTag = Java . type ( "org.zaproxy.addon.commonlib.CommonAlertTag" ) ;
7+
8+ function getMetadata ( ) {
9+ return ScanRuleMetadata . fromYaml ( `
10+ id: 100029
11+ name: "File Content Disclosure (CVE-2019-5418)"
12+ description: >
13+ The application seems to be subject to CVE-2019-5418.
14+ By sending a specially crafted request it was possible to have the target return
15+ data from the server file system.
16+ solution: >
17+ Upgrade to a version of Ruby/Rails where this issue is fixed. (See references for further details).
18+ references:
19+ - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-5418
20+ - https://github.com/mpgn/CVE-2019-5418
21+ category: injection
22+ risk: high
23+ confidence: medium
24+ cweId: 74 # CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
25+ wascId: 33 # WASC-33: Path Traversal
26+ alertTags:
27+ ${ CommonAlertTag . OWASP_2021_A03_INJECTION . getTag ( ) } : ${ CommonAlertTag . OWASP_2021_A03_INJECTION . getValue ( ) }
28+ ${ CommonAlertTag . OWASP_2017_A01_INJECTION . getTag ( ) } : ${ CommonAlertTag . OWASP_2017_A01_INJECTION . getValue ( ) }
29+ ${ CommonAlertTag . WSTG_V42_ATHZ_01_DIR_TRAVERSAL . getTag ( ) } : ${ CommonAlertTag . WSTG_V42_ATHZ_01_DIR_TRAVERSAL . getValue ( ) }
30+ status: alpha
31+ codeLink: https://github.com/zaproxy/community-scripts/blob/main/active/cve-2019-5418.js
32+ helpLink: https://www.zaproxy.org/docs/desktop/addons/community-scripts/
33+ ` ) ;
34+ }
3135
36+ function scanNode ( as , msg ) {
3237 var msg2 = msg . cloneRequest ( ) ;
3338 msg2
3439 . getRequestHeader ( )
@@ -40,21 +45,7 @@ data from the server file system.";
4045 var body = msg2 . getResponseBody ( ) . toString ( ) ;
4146
4247 if ( re . test ( body ) ) {
43- as . raiseAlert (
44- alertRisk ,
45- alertConfidence ,
46- alertTitle ,
47- alertDesc ,
48- url ,
49- "" ,
50- "" ,
51- alertInfo ,
52- alertSolution ,
53- body . match ( re ) [ 0 ] ,
54- cweId ,
55- wascId ,
56- msg2
57- ) ;
48+ as . newAlert ( ) . setEvidence ( body . match ( re ) [ 0 ] ) . setMessage ( msg2 ) . raise ( ) ;
5849 return ; // No need to try further
5950 }
6051 // Just in case there's a simple WaF
@@ -68,24 +59,6 @@ data from the server file system.";
6859 re = / 1 2 7 .0 .0 .1 / g;
6960 body = msg3 . getResponseBody ( ) . toString ( ) ;
7061 if ( re . test ( body ) ) {
71- as . raiseAlert (
72- alertRisk ,
73- alertConfidence ,
74- alertTitle ,
75- alertDesc ,
76- url ,
77- "" ,
78- "" ,
79- alertInfo ,
80- alertSolution ,
81- body . match ( re ) [ 0 ] ,
82- cweId ,
83- wascId ,
84- msg3
85- ) ;
62+ as . newAlert ( ) . setEvidence ( body . match ( re ) [ 0 ] ) . setMessage ( msg3 ) . raise ( ) ;
8663 }
8764}
88-
89- function scan ( as , msg , param , value ) {
90- //Unused
91- }
0 commit comments