Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status for MRI-related security issues? #5126

Closed
thbar opened this issue Mar 31, 2018 · 6 comments
Closed

Status for MRI-related security issues? #5126

thbar opened this issue Mar 31, 2018 · 6 comments
Milestone

Comments

@thbar
Copy link
Contributor

thbar commented Mar 31, 2018

I'm maintaining Ruby installations for a client on a regular basis (including both MRI & JRuby on various servers).

MRI got multiple releases to cover multiple CVEs:

Before that, MRI got other fixes recently:

I wondered what the situation is for JRuby with regard to the related CVEs.

The JRuby security page doesn't mention recent CVEs, and the news page hasn't had one for a while if I'm not mistaken.

Does this means that JRuby is unaffected (e.g. if it uses different, underlying JVM components rather than pure Ruby code), or that the evaluation hasn't necessarily been conducted so situation is unknown?

I don't know if opening an issue is the way to go for this, but I thought it is worth clarifying, so this could start a discussion!

Thanks for your work on JRuby.

@thbar
Copy link
Contributor Author

thbar commented Mar 31, 2018

PS: I do realise that like anything else, asserting & following all this takes time, and that resources are limited - I don't feel entitled to anything, just wondering what is the current status! Thanks.

@headius
Copy link
Member

headius commented Apr 11, 2018

We have been monitoring the various CVEs but have not been able to review them all. In general, most CVEs for CRuby don't apply to JRuby because they involve unsafe memory accesses that are not possible on the JVM. In native code, usually only DoS-type issues will also apply to JRuby, since much of our code uses the same algorithms as CRuby.

Any CVE that affects the Ruby-based standard library merits investigation. We ship a largely-unmodified copy of CRuby's standard library. That has not been updated in the 9.1 line since around Ruby 2.3.2 timeframe, so any CVEs affecting it after that time should get incorporated. I believe we have held off updating the standard library mostly because we expected JRuby 9.2 to be finished sooner, with support for current 2.4 or 2.5 and current stdlib to go with them.

@headius headius added this to the JRuby 9.1.17.0 milestone Apr 11, 2018
@headius
Copy link
Member

headius commented Apr 12, 2018

I'm going to bump this to 9.2 so we have time to review these CVEs. We could use some help figuring out which ones might affect JRuby...they hide the related commits rather well.

@headius headius modified the milestones: JRuby 9.1.17.0, JRuby 9.2.0.0 Apr 12, 2018
@enebo enebo modified the milestones: JRuby 9.2.0.0, JRuby 9.2.1.0 May 24, 2018
@headius headius modified the milestones: JRuby 9.2.1.0, JRuby 9.3.0.0 Oct 26, 2018
headius added a commit that referenced this issue Apr 7, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
See #5126
@headius
Copy link
Member

headius commented Apr 7, 2021

Reviewing the releases mentioned, plus all releases after 2.5.1. Some of these have specs in ruby/spec/security, which we pass (except one failure for Array#pack tainting which we do not support and which is deprecated in Ruby). Note that these likely have the same status on 9.2 (which also tracks latest stdlib and gems) but a separate review should be done. I review 9.3 for pre-release here.

Individually reviewing the various security disclosures below:

  • CVE-2017-17742: HTTP response splitting in WEBrick
  • CVE-2017-10784: Escape sequence injection vulnerability in the Basic authentication of WEBrick
  • CVE-2018-8777: DoS by large request in WEBrick
  • CVE-2019-16201: Regular Expression Denial of Service vulnerability of WEBrick’s Digest access authentication
  • CVE-2019-16254: HTTP response splitting in WEBrick (Additional fix)
  • CVE-2020-25613: Potential HTTP Request Smuggling Vulnerability in WEBrick

JRuby tracks latest WEBrick gem in 9.3 and uses it without modification. We will do a final update before release. CVE-2017-17742 is also tested by a security spec.

  • CVE-2018-6914: Unintentional file and directory creation with directory traversal in tempfile and tmpdir
  • CVE-2021-28966: Path traversal in Tempfile on Windows

JRuby reuses relevant portions of CRuby's tempfile library (recently updated and will be updated again before release) with a native implementation of Tempfile itself based on IO. CVE-2018-6914 is also tested in specs. CVE-2021-28966 involves the tmpdir library, which JRuby tracks from CRuby's 2.6 HEAD.

Largely applies only to the C implementation, but is also tested in specs.

  • CVE-2018-8779: Unintentional socket creation by poisoned NUL byte in UNIXServer and UNIXSocket
  • CVE-2018-8780: Unintentional directory traversal by poisoned NUL byte in Dir
  • CVE-2019-15845: A NUL injection vulnerability of File.fnmatch and File.fnmatch?

NUL bytes do not leak out to native calls in most cases in JRuby. In addition, the Dir and File functionality is provided by JDK APIs that are also safe. CVE-2018-8779 and CVE-2018-8780 are tested in specs.

  • Multiple vulnerabilities in RubyGems
  • Unsafe Object Deserialization Vulnerability in RubyGems

JRuby tracks latest RubyGems and was updated recently (#6533)

Buffer underruns will result in JVM exceptions on JRuby and do not constitute a memory vulnerability (and we did not have these bugs to begin with).

  • CVE-2013-0269 Denial of Service and Unsafe Object Creation Vulnerability in JSON
  • CVE-2017-14064: Heap exposure vulnerability in generating JSON
  • CVE-2020-10663: Unsafe Object Creation Vulnerability in JSON (Additional fix)

JRuby is unaffected due to the impossibility of exposing raw heap state to the Java-based JSON extension. We also track the latest json gem, which has a Java implementation for JRuby less subject to memory vulnerabilities.

  • Updated bundled libyaml to version 0.1.7

JRuby implements Psych (which wraps libyaml in CRuby) using SnakeYAML, and is current as of recent releases of Psych.

JRuby tracks the latest net-ftp gem.

  • CVE-2018-16396: Tainted flags are not propagated in Array#pack and String#unpack with some directives

This is the aforementioned failure in security specs. Tainting is no longer a supported feature, even in CRuby.

  • CVE-2018-16395: OpenSSL::X509::Name equality check does not work correctly

JRuby was unaffected and passes the relevant tests, added in 9619fca.

  • Multiple jQuery vulnerabilities in RDoc

JRuby tracks the latest rdoc gem.

  • CVE-2019-16255: A code injection vulnerability of Shell#[] and Shell#test

JRuby tracks the latest shell gem.

Another case where the JVM protects us from exposing the raw heap. JRuby's socket library largely uses JDK sockets in 9.3.

JRuby tracks the latest rexml gem.

@headius
Copy link
Member

headius commented Apr 7, 2021

Given that all CVEs to date appear to be addressed by using latest gems, latest copies from stdlib, or involve C-level vulnerabilities, I am calling this one fixed as of 9.3.

@headius headius closed this as completed Apr 7, 2021
@thbar
Copy link
Contributor Author

thbar commented Apr 7, 2021

Great work, thanks @headius!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants