Get a Pentest and security assessment of your IT network.

Cyber Security

Untrusted HTTPS Certificates: Server-to-Server Attack Risks

TL;DR

Using untrusted (self-signed or invalidly chained) HTTPS certificates for server-to-server communication opens you up to Man-in-the-Middle (MitM) attacks. An attacker can intercept traffic, read sensitive data, and even modify communications without either server knowing. Always use properly issued certificates from a trusted Certificate Authority (CA).

Understanding the Risks

When servers talk to each other over HTTPS with untrusted certificates, they don’t verify the identity of the other server. This is because verification relies on a chain of trust back to a CA that both servers recognise. Without this trust, an attacker can present their own certificate and pretend to be either server.

Attack Vectors

  1. Man-in-the-Middle (MitM) Attacks: This is the primary risk. An attacker positions themselves between your servers, intercepts all HTTPS traffic, decrypts it (because of the untrusted certificate), reads/modifies data, and then re-encrypts it before sending it on to the intended recipient.
  2. Data Theft: Sensitive information like API keys, user credentials, or financial data can be stolen during transmission.
  3. Data Manipulation: Attackers can alter requests or responses, leading to incorrect processing, corrupted data, or even malicious actions being performed.
  4. Service Disruption: An attacker could inject errors into the communication stream, causing services to fail.

Mitigation Steps

  1. Use Certificates from a Trusted CA: This is the most important step. Purchase certificates from well-known CAs like Let’s Encrypt (free), DigiCert, Sectigo, or GlobalSign. These certificates are pre-trusted by most systems and browsers.
  2. Proper Certificate Validation: Ensure your servers properly validate the certificate presented by the other server.
    • Check Expiry Date: Certificates expire! Expired certificates invalidate trust.
    • Verify Chain of Trust: Confirm that the certificate chain is complete and leads back to a trusted root CA.
    • Hostname Verification: The certificate’s Common Name (CN) or Subject Alternative Names (SANs) must match the hostname you are connecting to.
  3. Mutual TLS (mTLS): Implement mTLS, where both servers authenticate each other using certificates. This adds an extra layer of security.
    # Example: Configuring Nginx for mTLS
    ssl_certificate /path/to/server.crt;
    ssl_certificate_key /path/to/server.key;
    ssl_client_certificate /path/to/ca.crt;
    ssl_verify_client on;
    
  4. Certificate Pinning (with Caution): Pinning involves hardcoding the expected certificate or public key in your application. This prevents MitM attacks even if a CA is compromised, but it’s risky – if the certificate changes legitimately, your application will break. Use with extreme care and have robust update mechanisms.
    # Example: Certificate pinning in Python (using requests library)
    import requests
    
    cert_path = '/path/to/server.crt'
    requests.get('https://your-server.com', verify=cert_path) # Pinning to a specific certificate file
    
  5. Network Segmentation: Limit network access between servers to only what is necessary. This reduces the potential impact of a compromised server.
    • Use firewalls to restrict traffic based on IP address and port.
    • Consider using Virtual Private Networks (VPNs) for secure communication.
  6. Regular Security Audits: Conduct regular security audits of your server configurations and applications to identify vulnerabilities.

Detecting Untrusted Certificate Usage

  1. Monitoring Tools: Use tools like SSL Labs Server Test (https://www.ssllabs.com/ssltest/) to check your server’s certificate configuration and identify any issues.
  2. Log Analysis: Monitor your server logs for errors related to certificate validation failures.
Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation