@@ -275,7 +275,7 @@ trait CommonTests {
275
275
assert exploit. frames[2 ]. line == 15
276
276
}
277
277
278
- static Stream<Arguments > getTestData () {
278
+ static Stream<Arguments > getTestLfiData () {
279
279
return Arrays . stream(new Arguments []{
280
280
Arguments . of(" file_put_contents" , " /tmp/dummy" , 9 ),
281
281
Arguments . of(" readfile" , " /tmp/dummy" , 15 ),
@@ -285,8 +285,8 @@ trait CommonTests {
285
285
}
286
286
287
287
@ParameterizedTest
288
- @MethodSource (" getTestData " )
289
- void ' file_put_contents generates LFI signal' (String target_function, String path, Integer line) {
288
+ @MethodSource (" getTestLfiData " )
289
+ void ' filesystem functions generate LFI signal' (String target_function, String path, Integer line) {
290
290
HttpRequest req = container. buildReq(' /filesystem.php?function=' + target_function+ " &path=" + path). GET (). build()
291
291
def trace = container. traceFromRequest(req, ofString()) { HttpResponse<String > re ->
292
292
assert re. statusCode() == 200
@@ -528,4 +528,52 @@ trait CommonTests {
528
528
throw new AssertionError (" Module has STATIC_TLS flag: $res . stdout " )
529
529
}
530
530
}
531
+
532
+ static Stream<Arguments > getTestSsrfData() {
533
+ return Arrays . stream(new Arguments []{
534
+ Arguments . of(" file_get_contents" , 12 ),
535
+ Arguments . of(" fopen" , 9 ),
536
+ });
537
+ }
538
+
539
+ @ParameterizedTest
540
+ @MethodSource (" getTestSsrfData" )
541
+ void ' filesystem functions generate SSRF signal' (String target_function, Integer line) {
542
+ HttpRequest req = container. buildReq(' /ssrf.php?function=' + target_function+ " &domain=169.254.169.254" ). GET (). build()
543
+ def trace = container. traceFromRequest(req, ofString()) { HttpResponse<String > re ->
544
+ assert re. statusCode() == 200
545
+ assert re. body(). contains(' OK' )
546
+ }
547
+
548
+ Span span = trace. first()
549
+
550
+ assert span. metrics. " _dd.appsec.enabled" == 1.0d
551
+ assert span. metrics. " _dd.appsec.waf.duration" > 0.0d
552
+ assert span. meta. " _dd.appsec.event_rules.version" != ' '
553
+
554
+ InputStream stream = new ByteArrayInputStream ( span. meta_struct. " _dd.stack" . decodeBase64() )
555
+ MessageUnpacker unpacker = MessagePack . newDefaultUnpacker(stream)
556
+ List<Object > stacks = []
557
+ stacks << MsgpackHelper . unpackSingle(unpacker)
558
+ Object exploit = stacks. first(). exploit. first()
559
+
560
+ assert exploit. language == " php"
561
+ assert exploit. id ==~ / ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/
562
+ assert exploit. frames[0 ]. file == " ssrf.php"
563
+ assert exploit. frames[0 ]. function == target_function
564
+ assert exploit. frames[0 ]. id == 1
565
+ assert exploit. frames[0 ]. line == line
566
+ assert exploit. frames[1 ]. file == " ssrf.php"
567
+ assert exploit. frames[1 ]. function == " one"
568
+ assert exploit. frames[1 ]. id == 2
569
+ assert exploit. frames[1 ]. line == 18
570
+ assert exploit. frames[2 ]. file == " ssrf.php"
571
+ assert exploit. frames[2 ]. function == " two"
572
+ assert exploit. frames[2 ]. id == 3
573
+ assert exploit. frames[2 ]. line == 22
574
+ assert exploit. frames[3 ]. file == " ssrf.php"
575
+ assert exploit. frames[3 ]. function == " three"
576
+ assert exploit. frames[3 ]. id == 4
577
+ assert exploit. frames[3 ]. line == 25
578
+ }
531
579
}
0 commit comments