Skip to content

Commit 1c3133b

Browse files
authored
RASP capabilities for LFI is not sent when RASP is not fully enabled (#8573)
What Does This Do Only send RASP LFI capability if appsec is fully enabled Motivation Some RASP features have been implemented using callsite instrumentation, specifically LFI and partially SSRF. Since callsite instrumentation requires activation at application startup to function correctly, it will not work properly when RASP is dynamically enabled via 1-click activation.
1 parent 57fddd9 commit 1c3133b

File tree

2 files changed

+69
-6
lines changed

2 files changed

+69
-6
lines changed

Diff for: dd-java-agent/appsec/src/main/java/com/datadog/appsec/config/AppSecConfigServiceImpl.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,13 @@ private void subscribeConfigurationPoller() {
115115
if (tracerConfig.isAppSecRaspEnabled()) {
116116
capabilities |= CAPABILITY_ASM_RASP_SQLI;
117117
capabilities |= CAPABILITY_ASM_RASP_SSRF;
118-
capabilities |= CAPABILITY_ASM_RASP_LFI;
119118
capabilities |= CAPABILITY_ASM_RASP_CMDI;
120119
capabilities |= CAPABILITY_ASM_RASP_SHI;
120+
// RASP LFI is only available in fully enabled mode as it's implemented using callsite
121+
// instrumentation
122+
if (tracerConfig.getAppSecActivation() == ProductActivation.FULLY_ENABLED) {
123+
capabilities |= CAPABILITY_ASM_RASP_LFI;
124+
}
121125
}
122126
this.configurationPoller.addCapabilities(capabilities);
123127
}

Diff for: dd-java-agent/appsec/src/test/groovy/com/datadog/appsec/config/AppSecConfigServiceImplSpecification.groovy

+64-5
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class AppSecConfigServiceImplSpecification extends DDSpecification {
202202
then:
203203
1 * config.isAppSecRaspEnabled() >> true
204204
1 * config.getAppSecRulesFile() >> null
205-
1 * config.getAppSecActivation() >> ProductActivation.ENABLED_INACTIVE
205+
2 * config.getAppSecActivation() >> ProductActivation.ENABLED_INACTIVE
206206
1 * poller.addListener(Product.ASM_FEATURES, _, _) >> {
207207
listeners.savedFeaturesDeserializer = it[1]
208208
listeners.savedFeaturesListener = it[2]
@@ -239,7 +239,7 @@ class AppSecConfigServiceImplSpecification extends DDSpecification {
239239
then:
240240
1 * config.isAppSecRaspEnabled() >> true
241241
1 * config.getAppSecRulesFile() >> null
242-
1 * config.getAppSecActivation() >> ProductActivation.ENABLED_INACTIVE
242+
2 * config.getAppSecActivation() >> ProductActivation.ENABLED_INACTIVE
243243
1 * poller.addListener(Product.ASM_DD, _, _) >> {
244244
listeners.savedConfDeserializer = it[1]
245245
listeners.savedConfChangesListener = it[2]
@@ -273,7 +273,6 @@ class AppSecConfigServiceImplSpecification extends DDSpecification {
273273
| CAPABILITY_ASM_RASP_SSRF
274274
| CAPABILITY_ASM_RASP_CMDI
275275
| CAPABILITY_ASM_RASP_SHI
276-
| CAPABILITY_ASM_RASP_LFI
277276
| CAPABILITY_ENDPOINT_FINGERPRINT
278277
| CAPABILITY_ASM_SESSION_FINGERPRINT
279278
| CAPABILITY_ASM_NETWORK_FINGERPRINT
@@ -393,7 +392,7 @@ class AppSecConfigServiceImplSpecification extends DDSpecification {
393392
then:
394393
1 * config.isAppSecRaspEnabled() >> true
395394
1 * config.getAppSecRulesFile() >> null
396-
1 * config.getAppSecActivation() >> ProductActivation.ENABLED_INACTIVE
395+
2 * config.getAppSecActivation() >> ProductActivation.ENABLED_INACTIVE
397396
1 * poller.addListener(Product.ASM_DD, _, _) >> {
398397
listeners.savedConfDeserializer = it[1]
399398
listeners.savedConfChangesListener = it[2]
@@ -427,7 +426,6 @@ class AppSecConfigServiceImplSpecification extends DDSpecification {
427426
| CAPABILITY_ASM_RASP_SSRF
428427
| CAPABILITY_ASM_RASP_CMDI
429428
| CAPABILITY_ASM_RASP_SHI
430-
| CAPABILITY_ASM_RASP_LFI
431429
| CAPABILITY_ENDPOINT_FINGERPRINT
432430
| CAPABILITY_ASM_SESSION_FINGERPRINT
433431
| CAPABILITY_ASM_NETWORK_FINGERPRINT
@@ -564,6 +562,67 @@ class AppSecConfigServiceImplSpecification extends DDSpecification {
564562
autoUserInstrum('yolo') | DISABLED
565563
}
566564

565+
void 'RASP capabilities for LFI is not sent when RASP is not fully enabled '() {
566+
AppSecModuleConfigurer.SubconfigListener subconfigListener = Mock()
567+
SavedListeners listeners = new SavedListeners()
568+
Optional<CurrentAppSecConfig> initialWafConfig
569+
570+
when:
571+
AppSecSystem.active = false
572+
appSecConfigService.init()
573+
appSecConfigService.maybeSubscribeConfigPolling()
574+
def configurer = appSecConfigService.createAppSecModuleConfigurer()
575+
initialWafConfig = configurer.addSubConfigListener("waf", subconfigListener)
576+
configurer.commit()
577+
578+
then:
579+
1 * config.isAppSecRaspEnabled() >> true
580+
1 * config.getAppSecRulesFile() >> null
581+
2 * config.getAppSecActivation() >> ProductActivation.FULLY_ENABLED
582+
1 * poller.addListener(Product.ASM_DD, _, _) >> {
583+
listeners.savedConfDeserializer = it[1]
584+
listeners.savedConfChangesListener = it[2]
585+
}
586+
1 * poller.addListener(Product.ASM_DATA, _, _) >> {
587+
listeners.savedWafDataDeserializer = it[1]
588+
listeners.savedWafDataChangesListener = it[2]
589+
}
590+
1 * poller.addListener(Product.ASM, _, _) >> {
591+
listeners.savedWafRulesOverrideDeserializer = it[1]
592+
listeners.savedWafRulesOverrideListener = it[2]
593+
}
594+
1 * poller.addListener(Product.ASM_FEATURES, _, _) >> {
595+
listeners.savedFeaturesDeserializer = it[1]
596+
listeners.savedFeaturesListener = it[2]
597+
}
598+
1 * poller.addConfigurationEndListener(_) >> { listeners.savedConfEndListener = it[0] }
599+
1 * poller.addCapabilities(CAPABILITY_ASM_API_SECURITY_SAMPLE_RATE)
600+
1 * poller.addCapabilities(CAPABILITY_ASM_AUTO_USER_INSTRUM_MODE)
601+
1 * poller.addCapabilities(CAPABILITY_ASM_DD_RULES
602+
| CAPABILITY_ASM_IP_BLOCKING
603+
| CAPABILITY_ASM_EXCLUSIONS
604+
| CAPABILITY_ASM_EXCLUSION_DATA
605+
| CAPABILITY_ASM_REQUEST_BLOCKING
606+
| CAPABILITY_ASM_USER_BLOCKING
607+
| CAPABILITY_ASM_CUSTOM_RULES
608+
| CAPABILITY_ASM_CUSTOM_BLOCKING_RESPONSE
609+
| CAPABILITY_ASM_TRUSTED_IPS
610+
| CAPABILITY_ASM_RASP_SQLI
611+
| CAPABILITY_ASM_RASP_SSRF
612+
| CAPABILITY_ASM_RASP_CMDI
613+
| CAPABILITY_ASM_RASP_SHI
614+
| CAPABILITY_ASM_RASP_LFI
615+
| CAPABILITY_ENDPOINT_FINGERPRINT
616+
| CAPABILITY_ASM_SESSION_FINGERPRINT
617+
| CAPABILITY_ASM_NETWORK_FINGERPRINT
618+
| CAPABILITY_ASM_HEADER_FINGERPRINT)
619+
0 * _._
620+
initialWafConfig.get() != null
621+
622+
cleanup:
623+
AppSecSystem.active = true
624+
}
625+
567626
private static AppSecFeatures autoUserInstrum(String mode) {
568627
return new AppSecFeatures().tap { features ->
569628
features.autoUserInstrum = new AppSecFeatures.AutoUserInstrum().tap { instrum ->

0 commit comments

Comments
 (0)