Ruby/tzinfo/0.3.45


TZInfo provides access to time zone data and allows times to be converted using time zone rules.

https://rubygems.org/gems/tzinfo
MIT

1 Security Vulnerabilities

TZInfo relative path traversal vulnerability allows loading of arbitrary files

Published date: 2022-07-21T21:39:29Z
CVE: CVE-2022-31163
Links:

Impact

Affected versions

  • 0.3.60 and earlier.
  • 1.0.0 to 1.2.9 when used with the Ruby data source (tzinfo-data).

Vulnerability

With the Ruby data source (the tzinfo-data gem for tzinfo version 1.0.0 and later and built-in to earlier versions), time zones are defined in Ruby files. There is one file per time zone. Time zone files are loaded with require on demand. In the affected versions, TZInfo::Timezone.get fails to validate time zone identifiers correctly, allowing a new line character within the identifier. With Ruby version 1.9.3 and later, TZInfo::Timezone.get can be made to load unintended files with require, executing them within the Ruby process.

For example, with version 1.2.9, you can run the following to load a file with path /tmp/payload.rb:

TZInfo::Timezone.get("foo\n/../../../../../../../../../../../../../../../../tmp/payload")

The exact number of parent directory traversals needed will vary depending on the location of the tzinfo-data gem.

TZInfo versions 1.2.6 to 1.2.9 can be made to load files from outside of the Ruby load path. Versions up to and including 1.2.5 can only be made to load files from directories within the load path.

This could be exploited in, for example, a Ruby on Rails application using tzinfo version 1.2.9, that allows file uploads and has a time zone selector that accepts arbitrary time zone identifiers. The CVSS score and severity have been set on this basis.

Versions 2.0.0 and later are not vulnerable.

Patches

Versions 0.3.61 and 1.2.10 include fixes to correctly validate time zone identifiers (commit 9eddbb5c0e682736f61d0dd803b6031a5db9eadf for 0.3.x and commit 9905ca93abf7bf3e387bd592406e403cd18334c7 for 1.2.x).

Note that version 0.3.61 can still load arbitrary files from the Ruby load path if their name follows the rules for a valid time zone identifier and the file has a prefix of tzinfo/definition within a directory in the load path. For example if /tmp/upload was in the load path, then TZInfo::Timezone.get('foo') could load a file with path /tmp/upload/tzinfo/definition/foo.rb. Applications should ensure that untrusted files are not placed in a directory on the load path.

Workarounds

As a workaround, the time zone identifier can be validated before passing to TZInfo::Timezone.get by ensuring it matches the regular expression \A[A-Za-z0-9+\-_]+(?:\/[A-Za-z0-9+\-_]+)*\z.

For more information

If you have any questions or comments about this advisory: - Open an issue in the tzinfo repository.

Affected versions: ["1.2.7", "1.2.6", "1.2.5", "1.2.4", "1.2.3", "1.2.2", "1.2.1", "1.2.0", "1.1.0", "1.0.1", "1.0.0", "1.2.8", "1.2.9", "0.3.57", "0.3.56", "0.3.55", "0.3.54", "0.3.53", "0.3.52", "0.3.51", "0.3.50", "0.3.49", "0.3.48", "0.3.47", "0.3.46", "0.3.45", "0.3.44", "0.3.43", "0.3.42", "0.3.41", "0.3.40", "0.3.39", "0.3.38", "0.3.37", "0.3.36", "0.3.35", "0.3.34", "0.3.33", "0.3.32", "0.3.31", "0.3.30", "0.3.29", "0.3.28", "0.3.27", "0.3.26", "0.3.25", "0.3.24", "0.3.23", "0.3.22", "0.3.21", "0.3.20", "0.3.19", "0.3.18", "0.3.17", "0.3.16", "0.3.15", "0.3.14", "0.3.13", "0.3.12", "0.3.11", "0.3.10", "0.3.9", "0.3.8", "0.3.7", "0.3.6", "0.3.5", "0.3.4", "0.3.3", "0.3.2", "0.3.1", "0.3.0", "0.2.2", "0.2.1", "0.2.0", "0.1.2", "0.1.1", "0.1.0", "0.0.4", "0.0.3", "0.0.2", "0.0.1", "0.3.58", "0.3.59", "0.3.60"]
Secure versions: [2.0.2, 2.0.1, 2.0.0, 2.0.3, 2.0.4, 2.0.5, 1.2.10, 0.3.61, 2.0.6, 1.2.11, 0.3.62]
Recommendation: Update to version 2.0.6.

95 Other Versions

Version License Security Released
2.0.6 MIT 2023-01-28 - 20:27 about 1 year
2.0.5 MIT 2022-07-19 - 19:14 over 1 year
2.0.4 MIT 2020-12-16 - 22:47 over 3 years
2.0.3 MIT 2020-11-08 - 13:50 over 3 years
2.0.2 MIT 2020-04-02 - 21:42 almost 4 years
2.0.1 MIT 2019-12-24 - 17:16 over 4 years
2.0.0 MIT 2018-12-26 - 20:01 over 5 years
1.2.11 MIT 2023-01-28 - 20:26 about 1 year
1.2.10 MIT 2022-07-19 - 18:27 over 1 year
1.2.9 MIT 2 2020-12-16 - 22:46 over 3 years
1.2.8 MIT 2 2020-11-08 - 12:20 over 3 years
1.2.7 MIT 2 2020-04-02 - 21:42 almost 4 years
1.2.6 MIT 2 2019-12-24 - 16:54 over 4 years
1.2.5 MIT 2 2018-02-04 - 19:58 about 6 years
1.2.4 MIT 2 2017-10-26 - 22:18 over 6 years
1.2.3 MIT 2 2017-03-25 - 18:43 about 7 years
1.2.2 MIT 2 2014-08-08 - 18:00 over 9 years
1.2.1 MIT 2 2014-06-01 - 14:57 almost 10 years
1.2.0 MIT 2 2014-05-26 - 14:10 almost 10 years
1.1.0 MIT 2 2013-09-25 - 22:42 over 10 years
1.0.1 MIT 2 2013-06-22 - 17:30 almost 11 years
1.0.0 MIT 2 2013-06-02 - 17:05 almost 11 years
0.3.62 MIT 2023-04-10 - 12:46 12 months
0.3.61 MIT 2022-07-19 - 18:26 over 1 year
0.3.60 MIT 1 2021-02-06 - 19:48 about 3 years
0.3.59 MIT 1 2020-12-24 - 20:08 over 3 years
0.3.58 MIT 1 2020-11-08 - 11:23 over 3 years
0.3.57 MIT 1 2020-05-17 - 09:37 almost 4 years
0.3.56 MIT 1 2019-11-01 - 18:31 over 4 years
0.3.55 MIT 1 2018-10-27 - 18:09 over 5 years
0.3.54 MIT 1 2018-03-25 - 15:37 about 6 years
0.3.53 MIT 1 2017-03-23 - 20:40 about 7 years
0.3.52 MIT 1 2016-10-28 - 18:04 over 7 years
0.3.51 MIT 1 2016-07-05 - 21:49 over 7 years
0.3.50 MIT 1 2016-06-14 - 20:28 almost 8 years
0.3.49 MIT 1 2016-04-18 - 21:52 almost 8 years
0.3.48 MIT 1 2016-03-23 - 23:58 about 8 years
0.3.47 MIT 1 2016-03-15 - 23:20 about 8 years
0.3.46 MIT 1 2015-12-02 - 23:40 over 8 years
0.3.45 MIT 1 2015-10-03 - 15:07 over 8 years
0.3.44 MIT 1 2015-04-24 - 22:19 almost 9 years
0.3.43 MIT 1 2015-01-31 - 20:24 about 9 years
0.3.42 MIT 1 2014-10-23 - 20:12 over 9 years
0.3.41 MIT 1 2014-08-08 - 19:13 over 9 years
0.3.40 MIT 1 2014-07-10 - 20:57 over 9 years
0.3.39 MIT 1 2014-03-09 - 20:19 about 10 years
0.3.38 UNKNOWN 1 2013-10-08 - 22:28 over 10 years
0.3.37 UNKNOWN 1 2013-03-11 - 22:38 about 11 years
0.3.36 UNKNOWN 1 2013-03-03 - 16:26 about 11 years
0.3.35 UNKNOWN 1 2012-11-04 - 23:02 over 11 years
0.3.34 UNKNOWN 1 2012-10-27 - 15:25 over 11 years
0.3.33 UNKNOWN 1 2012-04-08 - 15:47 almost 12 years
0.3.32 UNKNOWN 1 2012-03-04 - 16:04 about 12 years
0.3.31 UNKNOWN 1 2011-11-06 - 16:45 over 12 years
0.3.30 UNKNOWN 1 2011-09-29 - 22:10 over 12 years
0.3.29 UNKNOWN 1 2011-06-27 - 22:08 almost 13 years
0.3.28 UNKNOWN 1 2011-06-13 - 21:41 almost 13 years
0.3.27 UNKNOWN 1 2011-04-26 - 20:01 almost 13 years
0.3.26 UNKNOWN 1 2011-04-02 - 16:11 almost 13 years
0.3.25 UNKNOWN 1 2011-03-14 - 20:29 about 13 years
0.3.24 UNKNOWN 1 2011-01-15 - 12:47 about 13 years
0.3.23 UNKNOWN 1 2010-08-19 - 22:03 over 13 years
0.3.22 UNKNOWN 1 2010-05-29 - 08:12 almost 14 years
0.3.21 UNKNOWN 1 2010-05-28 - 21:34 almost 14 years
0.3.20 UNKNOWN 1 2010-04-19 - 21:37 almost 14 years
0.3.19 UNKNOWN 1 2010-04-05 - 21:31 almost 14 years
0.3.18 UNKNOWN 1 2010-03-29 - 21:45 almost 14 years
0.3.17 UNKNOWN 1 2010-03-08 - 22:03 about 14 years
0.3.16 UNKNOWN 1 2010-01-05 - 22:14 about 14 years
0.3.15 UNKNOWN 1 2009-10-27 - 01:50 over 14 years
0.3.14 UNKNOWN 1 2009-08-20 - 05:42 over 14 years
0.3.13 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.12 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.11 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.10 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.9 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.8 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.7 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.6 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.5 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.4 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.3 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.2 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.1 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.3.0 UNKNOWN 1 2009-07-25 - 17:48 over 14 years
0.2.2 UNKNOWN 2 2009-07-25 - 17:48 over 14 years
0.2.1 UNKNOWN 2 2009-07-25 - 17:48 over 14 years
0.2.0 UNKNOWN 2 2009-07-25 - 17:48 over 14 years
0.1.2 UNKNOWN 2 2009-07-25 - 17:48 over 14 years
0.1.1 UNKNOWN 2 2009-07-25 - 17:48 over 14 years
0.1.0 UNKNOWN 2 2009-07-25 - 17:48 over 14 years
0.0.4 UNKNOWN 2 2009-07-25 - 17:48 over 14 years
0.0.3 UNKNOWN 2 2009-07-25 - 17:48 over 14 years
0.0.2 UNKNOWN 2 2009-07-25 - 17:48 over 14 years
0.0.1 UNKNOWN 2 2009-07-25 - 17:48 over 14 years