This product is not supported for your selected Datadog site. ().
Metadata
ID:java-security/no-trust-strategy
Language: Java
Severity: Info
Category: Best Practices
Description
This rule flags the use of TrustStrategy implementations such as TrustSelfSignedStrategy and TrustAllStrategy that accept certificates without proper validation. These strategies inherently trust certificates blindly, which undermines the security guarantees of SSL/TLS connections and exposes applications to man-in-the-middle attacks.
Using such TrustStrategies is dangerous because it bypasses critical certificate verification steps, allowing potentially untrusted or malicious certificates to be accepted. This can lead to sensitive data exposure, unauthorized access, and other security vulnerabilities in your application.
To comply with this rule, avoid using TrustStrategies that indiscriminately trust certificates. Instead, ensure that your SSLContext is configured with proper trust material that enforces rigorous certificate validation.
importjavax.net.ssl.SSLContext;publicclassContextMaker{publicstaticSSLContextmakeSecure()throwsException{// Safe: using default trust material with proper certificate validationreturnSSLContext.getDefault();}}
Seamless integrations. Try Datadog Code Security
Datadog Code Security
Try this rule and analyze your code with Datadog Code Security
How to use this rule
1
2
rulesets:- java-security # Rules to enforce Java security.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Security scans to your CI pipelines