VDB
Sign up
MEDIUM

GHSA-72qj-48g4-5xgx

JRuby-OpenSSL has hostname verification disabled by default

Quick fix

GHSA-72qj-48g4-5xgx — rubygems:jruby-openssl: upgrade to the fixed version with the command below.

# pom.xml: bump <version>0.15.4</version> for rubygems:jruby-openssl

Details

### Summary When verifying SSL certificates, jruby-openssl is not verifying that the hostname presented in the certificate matches the one we are trying to connect to, meaning a MITM could just present _any_ valid cert for a completely different domain they own, and JRuby wouldn't complain.

### Details n/a

### PoC An example domain bad.substitutealert.com was created to present the a certificate for the domain s8a.me. The following script run in IRB in CRuby 3.4.3 will fail with `certificate verify failed (hostname mismatch)`, but will work just fine in JRuby 10.0.0.0 and JRuby 9.4.2.0, both of which use jruby-openssl version 0.15.3

```ruby require "net/http" require "openssl"

uri = URI("https://bad.substitutealert.com/") https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_PEER

body = https.start { https.get(uri.request_uri).body } puts body ```

### Impact Anybody using JRuby to make requests of external APIs, or scraping the web, that depends on https to connect securely

Are you affected?

Enter the version of the package you're using.

Affected packages

Maven/rubygems:jruby-openssl
Introduced in: 0.12.1Fixed in: 0.15.4
Fix# pom.xml: bump <version>0.15.4</version> for rubygems:jruby-openssl
Maven/org.jruby:jruby
Introduced in: 10.0.0.0Fixed in: 10.0.0.1
Fix# pom.xml: bump <version>10.0.0.1</version> for org.jruby:jruby
Maven/org.jruby:jruby
Introduced in: 9.3.4.0Fixed in: 9.4.12.1
Fix# pom.xml: bump <version>9.4.12.1</version> for org.jruby:jruby
RubyGems/jruby-openssl
Introduced in: 0.12.1Fixed in: 0.15.4
Fixbundle update jruby-openssl

References