Summary
MariaDB Connector/Node.js may send database credentials before completing server certificate validation when TLS is enabled without a pinned CA or server certificate. An active man-in-the-middle could present a fraudulent certificate, capture the password through the clear-password authentication flow, and use it to authenticate directly even though the connector later rejects the connection.
Affected context
The issue occurs in MariaDB Connector/Node.js connections that enable SSL or TLS without pinning a trusted CA or server certificate. Risk is higher when the server selects mysql_clear_password initially or requests an authentication switch, because credential transmission may occur before the connector finishes its post-TLS server identity check.
Exploit preconditions
- Attack surface: A network path between the Node.js application and the MariaDB or MySQL server
- Required access: Ability to intercept and influence database connection traffic
- Trigger point: TLS connection establishment followed by authentication negotiation
- Configuration condition: SSL or TLS is enabled without a pinned CA or server certificate
- Why exploitation is possible: Authentication credentials may be transmitted before certificate fingerprint validation completes
Why this happens
The vulnerability results from ordering and state-handling errors in the connector's TLS and authentication handshake. Credential transmission can occur before the peer identity has been fully validated, while authentication-switch processing may evaluate the previously selected plugin rather than the requested target plugin. This maps primarily to CWE-295: Improper Certificate Validation, with a related CWE-522: Insufficiently Protected Credentials, because an untrusted endpoint can receive database credentials before the connection is conclusively authenticated.
Potential impact
- An attacker could capture database passwords
- An attacker may authenticate directly to the database using stolen credentials
- Database records could be read, modified, or deleted
- Applications relying on the compromised database account could be affected
- Exposed credentials could be reused against other systems
General mitigation guidance
Mitigation generally focuses on ensuring that server identity is established before any credential transmission.
Common defensive patterns include:
- Pinning a trusted certificate authority or expected server certificate where operationally appropriate
- Configuring TLS verification to fail closed when certificate validation cannot be completed
- Avoiding clear-password authentication unless it is protected by a fully authenticated encrypted channel
- Using authentication mechanisms that do not transmit reusable credentials prematurely
- Restricting database-account privileges and separating application credentials by service
- Protecting database traffic from interception through network segmentation and authenticated proxies
- Maintaining connector dependencies through the organization's standard secure dependency-management process
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis of database connector configuration for disabled, incomplete, or non-pinned certificate verification
- Code review of TLS-handshake and authentication-switch state transitions
- Dependency and software-composition analysis for connector versions with known credential-ordering flaws
- Network monitoring for database authentication attempts involving unexpected endpoints or certificate identities
- Policy enforcement requiring verified server certificates and approved authentication plugins
- Automated security review tools that flag credential transmission before peer authentication

