Skip to main content

CVE-2026-54659 — Vulnerability in pagy — CVE Details

MEDIUM

Pagy I18n locale option is not validated before being used in a file path

Published July 28, 2026Updated July 28, 2026Source: OSV

What Should I Do?

Address in Next Maintenance Window

Low exploitation probability (0.54%). Schedule for your next planned update.

Does your project use an affected pagy version?

Paste your Gemfile.lock to check it for CVE-2026-54659 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my Gemfile.lock

Summary

Summary

Pagy::I18n.locale= did not validate its argument before using it as a path component to load the matching dictionary file (<locale>.yml). An application that assigns untrusted input to the locale — e.g. the common pattern Pagy::I18n.locale = params[:locale] — let that input influence which file Pagy attempted to load.

Details

The setter stored the value as-is, and the loader joined it into a path and read it:

# gem/lib/pagy/modules/i18n/i18n.rb
def locale=(value)
  Thread.current[:pagy_locale] = value.to_s
end

# ...later, when translating:
path = pathnames.reverse.map { |p| p.join("#{locale}.yml") }.find(&:exist?)
dictionary = YAML.load_file(path)[locale]

Because the locale was used verbatim, a value such as an absolute path or a ../-style string redirected the lookup outside the locales directory. Pagy's subsequent structural check (dictionary['pagy']['p11n']) prevents the file's contents from being returned, so this is not a direct file read.

Fixed in 43.5.6 by constraining the locale to a BCP 47 shape before use:

LOCALE_PATTERN = /\A[a-zA-Z]{2,8}(-[a-zA-Z0-9]{1,8})*\z/

def locale=(value)
  Thread.current[:pagy_locale] = value.to_s[LOCALE_PATTERN]
end

Any non-matching value (including nil) resolves to the default locale and never reaches the file lookup.

PoC

In an application that sets Pagy::I18n.locale = params[:locale], the loader appends .yml and reads <locale>.yml, so the request param controls the target path. For example, pointing it at the app's config/database.yml:

  1. Send a request with ?locale=../../../config/database (adjust the number of ../ to reach the app root from the gem's locales/ directory).
  2. Pagy calls YAML.load_file on the resulting …/config/database.yml.
  3. The outcome differs by whether that .yml exists, is readable, parses as YAML, and has Pagy's expected structure — an existing, readable config/database.yml raises a different error than a non-existent path (which silently falls back to the default locale). This yields a file-existence / readability oracle for .yml paths, and the targeted file is read into the process during the attempt.

Impact

Information disclosure (CWE-22 / CWE-200): a file-existence / readability oracle for .yml paths on the host, plus a server-side read of attacker-chosen files into the process. The file contents are not returned in the response.

Only applications that pass unsanitized end-user input into Pagy::I18n.locale= are affected. Applications that set the locale from trusted values are not affected.

Patched: pagy 43.5.6. Workaround (if you cannot upgrade): validate the locale before assigning it, e.g. Pagy::I18n.locale = params[:locale].to_s[/\A[a-zA-Z]{2,8}(-[a-zA-Z0-9]{1,8})*\z/], or restrict it to your known set of locales.

Advisory Timeline

  • First published July 28, 2026 (121 days ago).
  • Last revised July 28, 2026 — 0 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Bundler
Update pagy to 43.5.6 or later
gem install pagy -v 43.5.6

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (1)

Affects 1 ecosystem: RubyGems (1).

PackageFixed In
pagy RubyGems · Affected: 43.0.0, 43.0.1, 43.0.2, 43.0.3 (+39 more)43.5.6

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 5.3 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
—
Confidentiality
—
Integrity
—
Availability
—

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N

Frequently Asked Questions

What is CVE-2026-54659?
Pagy I18n locale option is not validated before being used in a file path. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 5.3/10).
How do I check if my project is affected by CVE-2026-54659?
CVE-2026-54659 affects pagy. It has a 0.5% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-54659 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
5.3

Exploitation requires specific conditions, or the impact is limited.

EPSS Score (30-day exploit probability)
0.54%
EPSS percentile: 39

This is a below-median EPSS score — only 39% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.

Also Known As

GHSA-2xmw-f8j8-wfxc

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my Gemfile.lock