Back to Blog
high SEVERITY3 min read

HTTP Client `danger_accept_invalid_certs` Permitted MITM Credential

The HTTP client's `validate_certs` parameter allowed disabling TLS certificate validation through `danger_accept_invalid_certs(true)`, exposing Basic Auth credentials to interception. The fix replaces this dangerous capability with a hard error, forcing developers to use proper certificate management instead.

O
By Orbis AppSec
•Technically reviewed by Anupam Mediratta•Published September 18, 2026•Reviewed September 18, 2026

Answer Summary

The `build_http_client` function's `validate_certs` parameter in the HTTP client permitted disabling all TLS certificate validation. An attacker on the same network could intercept credentials when users connected to servers with invalid certificates. The fix replaces the `danger_accept_invalid_certs(true)` call with an error return, removing the unsafe option entirely. CWE unknown.

Vulnerability at a Glance

cweN/A
fixReplace TLS bypass with hard error, require custom CA certificates instead
riskBasic Auth credentials transmitted without certificate validation, vulnerable to MITM attacks
languageRust
root cause`validate_certs` parameter enabled `danger_accept_invalid_certs(true)` without restriction
vulnerabilityInsecure TLS Configuration / Credential Exposure

Affected Versions

Affected not applicable (first-party code)
Fixed in not applicable (first-party code) — see fix commit
Ecosystem Rust (reqwest)
CVE / GHSA not assigned
CWE unknown

The Vulnerability Explained

A critical security flaw in the HTTP client configuration allowed any caller to disable TLS certificate validation entirely. The build_http_client function accepted a validate_certs boolean parameter that, when set to false, would invoke danger_accept_invalid_certs(true) on the underlying reqwest::ClientBuilder:

if !validate_certs {
    builder = builder.danger_accept_invalid_certs(true);
}

This is precisely the wrong way to handle certificate problems in production code. The danger_accept_invalid_certs method in reqwest is explicitly documented as dangerous—it disables all certificate validation, including hostname verification and trust chain checking. When combined with Basic Auth credentials, this creates a perfect storm: authentication secrets travel over connections that could be intercepted by any attacker positioned between the client and server.

The attack scenario is straightforward. A developer or automated system sets validate_certs to false to work around a certificate issue—perhaps a self-signed certificate in a staging environment, or an expired certificate on a legacy server. An attacker on the same network segment (public WiFi, compromised router, malicious hotspot, or ARP-spoofed LAN) presents a fake certificate for the target hostname. Without validation, the client accepts this certificate and establishes a TLS connection to the attacker. The attacker decrypts the traffic, extracts the Basic Auth credentials, then forwards the request to the real server—completely invisible to both parties.

The reqwest documentation warns that this setting "is highly discouraged and should only be used for debugging purposes." Yet the API made it available as a simple boolean toggle, with no audit trail, no warning, and no alternative path for legitimate certificate customization.

The Fix

The fix removes the dangerous escape hatch entirely. Instead of silently disabling security, the code now returns an error with clear guidance:

if !validate_certs {
    return Err(
        "Disabling TLS certificate validation is not permitted because it exposes credentials to man-in-the-middle attacks. Use a custom CA certificate instead.".to_string(),
    );
}

This change preserves all legitimate use cases through the existing use_custom_ca_certificate path, which properly validates certificates against a custom trust anchor rather than accepting any certificate whatsoever. The error message explicitly names the security risk and points developers toward the correct solution.

The before/after comparison reveals the shift in security posture:

Before After
Silent security downgrade Explicit failure with explanation
MITM vulnerability Credential protection
No alternative provided Directed to custom_ca_certificate_path

Key Takeaways

  • Never expose danger_accept_invalid_certs through a boolean parameter—the convenience of a quick toggle becomes the path of least resistance, and developers will use it in production without understanding the consequences.

  • Certificate problems have certificate solutions—self-signed certificates belong in a custom CA store, not in a bypassed validation path. The custom_ca_certificate_path option provides the flexibility without the exposure.

  • Error messages are security controls—the new error doesn't just stop dangerous behavior; it educates the developer about why the behavior is dangerous and what to do instead.

  • API design is threat modeling—the original design assumed that callers would responsibly use validate_certs. The fix assumes that dangerous capabilities will be misused, and removes them.

How Orbis AppSec Detected This

Source: The validate_certs parameter passed to build_http_client

Sink: reqwest::ClientBuilder.danger_accept_invalid_certs(true) invoked when certificate validation is disabled

Missing control: No restriction on when TLS validation could be disabled; no requirement for custom CA certificates as an alternative

CWE: unknown

Fix: Replace the dangerous TLS bypass with a hard error that directs developers toward proper certificate management

Orbis AppSec automatically detected this vulnerability and opened a pull request with the fix. Try Orbis AppSec on your repositories to find and fix issues like this automatically.

Conclusion

The validate_certs parameter was a foot-gun: an easy-to-use option that destroyed the security guarantees of TLS. The fix recognizes that developers facing certificate errors need guidance toward proper solutions, not an escape hatch that exposes credentials. By converting the silent vulnerability into an explicit error with actionable advice, the code now protects users while still supporting legitimate certificate customization through the custom_ca_certificate_path mechanism.

Prevention and further reading

Frequently Asked Questions

Does the `validate_certs` parameter still exist after the fix, and what happens when it's set to false?

The parameter still exists, but when `validate_certs` is false, the function now returns an error instead of disabling TLS validation. The error message directs developers to use custom CA certificates.

Is there any legitimate use case still supported for connecting to servers with non-standard certificates?

Yes. The `use_custom_ca_certificate` option with `custom_ca_certificate_path` remains fully functional. This provides the same flexibility without exposing credentials to man-in-the-middle attacks.

What Rust crate provides the `danger_accept_invalid_certs` method that was being misused here?

The `reqwest` HTTP client crate provides this method. It's intended for testing only and is explicitly marked as dangerous in the API documentation.

View the Security Fix

Check out the pull request that fixed this vulnerability

View PR #11

Related Articles

critical

Hybridauth Telegram OAuth Timing Attack in `authenticateCheckError()`

The Telegram OAuth provider in Hybridauth relied on `strcmp()` to validate HMAC-SHA256 signatures, exposing a timing side-channel that could allow attackers to forge authentication tokens character by character. The fix replaces this with PHP's timing-safe `hash_equals()` function, eliminating the information leak.

high

undici 7.29.0 TLS Bypass: BalancedPool Drops Connect Options

A critical flaw in undici's BalancedPool implementation silently discards TLS certificate validation settings when routing requests through certain connection paths. Attackers on the network could intercept HTTPS traffic without triggering validation errors. The fix preserves connect options throughout the connection lifecycle.

critical

Model Fetching Without Integrity Verification in ONNX Loading

A machine learning application was fetching ONNX model files and chunks over the network without verifying their integrity, creating an opening for model poisoning attacks. The fix adds cryptographic integrity verification at the point where downloaded chunks are reassembled and cached, ensuring models have not been modified in transit or at rest.

high

nanoid 3.3.11 Integer Overflow: Predictable ID Generation

An integer overflow in nanoid 3.3.11's internal randomness generation causes the library to fall back to predictable ID sequences, undermining the cryptographic guarantees of its supposedly unguessable identifiers. The fix upgrades the dependency tree to patched versions 3.3.12 or 5.1.11.

high

generateUUID() Ditches MD5 for SHA-256 to Fix CWE-328

The `generateUUID()` helper built request-identifying UUIDs by hashing an input string with MD5, a cryptographically broken algorithm susceptible to collisions. The fix swaps the hash function for SHA-256, reducing the chance that two different inputs produce the same generated identifier.

high

API_URL Defaults to HTTP Without HTTPS Enforcement

An API client defaults to unencrypted HTTP connections, leaving all API communications—including sensitive project data—vulnerable to interception. Although an `upgradeToHttps()` helper function existed, it was applied inconsistently across the codebase. The fix ensures HTTPS enforcement is applied uniformly before every HTTP request.