Skip to content

SSL Identity Check Bypass #313

@mikeburgh

Description

@mikeburgh

I was debugging the driver to resolve an SNI issue (trying to pass servername as an SSL option) and discovered what I think is an issue in the createSecureContext method:

createSecureContext(info, callback) {

If you supply a checkServerIdentity function in the ssl config, then it wont be called, and no SSL identity check will be performed, due to this line:

 info.requireIdentifyCheck = this.opts.ssl === true || this.opts.ssl.checkServerIdentity === undefined;

I think the last check should be !== undefined, since if it's defined then it should be used and an identity check performed.

However, that causes another issue in this line:

const sslOption = this.opts.ssl === true ? baseConf : Object.assign({}, this.opts.ssl, baseConf);

baseConf is applied over the supplied ssl options, rather than the other way around. This leads to the no op function in baseConf being used, and since it does not return (same as returning undefined) the check still passes.

If both of those are fixed, then this line in handshakeResult

const identityError = tls.checkServerIdentity(opts.host, info.tlsCert);

should probably change to something like:

const identityError = tls.checkServerIdentity(typeof opts.ssl === 'object' && opts.ssl.servername ? opts.ssl.servername : opts.host, info.tlsCert);

I can put all this in a PR if that's preferred ? Just wanted to confirm this is right, or am I missing something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions