{"id":"CVE-2026-54659","aliases":["CVE-2026-54659","GHSA-2xmw-f8j8-wfxc"],"related":[],"kind":"vulnerability","state":"published","title":"Pagy I18n locale option is not validated before being used in a file path","summary":"Pagy is agnostic pagination in plain Ruby. From 43.0.0 until 43.5.6, Pagy::I18n.locale= in gem/lib/pagy/modules/i18n/i18n.rb stored locale values verbatim and later used them as <locale>.yml path components, allowing untrusted params[:locale] values with absolute paths or ../ sequences to create a file existence and readability oracle for YAML files. This issue is fixed in version 43.5.6.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Pagy is agnostic pagination in plain Ruby. From 43.0.0 until 43.5.6, Pagy::I18n.locale= in gem/lib/pagy/modules/i18n/i18n.rb stored locale values verbatim and later used them as <locale>.yml path components, allowing untrusted params[:locale] values with absolute paths or ../ sequences to create a file existence and readability oracle for YAML files. This issue is fixed in version 43.5.6.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n`Pagy::I18n.locale=` did not validate its argument before using it as a\npath component to load the matching dictionary file (`<locale>.yml`). An\napplication that assigns untrusted input to the locale — e.g. the common\npattern `Pagy::I18n.locale = params[:locale]` — let that input influence\nwhich file Pagy attempted to load.\n\n### Details\n\nThe setter stored the value as-is, and the loader joined it into a path\nand read it:\n\n```ruby\n# gem/lib/pagy/modules/i18n/i18n.rb\ndef locale=(value)\n  Thread.current[:pagy_locale] = value.to_s\nend\n\n# ...later, when translating:\npath = pathnames.reverse.map { |p| p.join(\"#{locale}.yml\") }.find(&:exist?)\ndictionary = YAML.load_file(path)[locale]\n```\n\nBecause the locale was used verbatim, a value such as an absolute path or\na `../`-style string redirected the lookup outside the locales directory.\nPagy's subsequent structural check (`dictionary['pagy']['p11n']`)\nprevents the file's contents from being returned, so this is **not** a\ndirect file read.\n\nFixed in 43.5.6 by constraining the locale to a BCP 47 shape before use:\n\n```ruby\nLOCALE_PATTERN = /\\A[a-zA-Z]{2,8}(-[a-zA-Z0-9]{1,8})*\\z/\n\ndef locale=(value)\n  Thread.current[:pagy_locale] = value.to_s[LOCALE_PATTERN]\nend\n```\n\nAny non-matching value (including `nil`) resolves to the default locale\nand never reaches the file lookup.\n\n### PoC\n\nIn an application that sets `Pagy::I18n.locale = params[:locale]`, the\nloader appends `.yml` and reads `<locale>.yml`, so the request param\ncontrols the target path. For example, pointing it at the app's\n`config/database.yml`:\n\n1. Send a request with `?locale=../../../config/database` (adjust the\n   number of `../` to reach the app root from the gem's `locales/`\n   directory).\n2. Pagy calls `YAML.load_file` on the resulting `…/config/database.yml`.\n3. The outcome differs by whether that `.yml` exists, is readable, parses\n   as YAML, and has Pagy's expected structure — an existing, readable\n   `config/database.yml` raises a different error than a non-existent\n   path (which silently falls back to the default locale). This yields a\n   file-existence / readability oracle for `.yml` paths, and the targeted\n   file is read into the process during the attempt.\n\n### Impact\n\nInformation disclosure (CWE-22 / CWE-200): a file-existence / readability\noracle for `.yml` paths on the host, plus a server-side read of\nattacker-chosen files into the process. The file contents are not\nreturned in the response.\n\nOnly applications that pass **unsanitized end-user input** into\n`Pagy::I18n.locale=` are affected. Applications that set the locale from\ntrusted values are not affected.\n\n**Patched:** pagy 43.5.6.\n**Workaround (if you cannot upgrade):** validate the locale before\nassigning it, e.g.\n`Pagy::I18n.locale = params[:locale].to_s[/\\A[a-zA-Z]{2,8}(-[a-zA-Z0-9]{1,8})*\\z/]`,\nor restrict it to your known set of locales.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Pagy es paginación agnóstica en Ruby puro. Desde la versión 43.0.0 hasta la 43.5.6, Pagy::I18n.locale= en gem/lib/pagy/modules/i18n/i18n.rb almacenaba los valores de configuración regional textualmente y luego los usaba como componentes de ruta de [locale].yml, permitiendo que valores no confiables de params[:locale] con rutas absolutas o secuencias .. /  crearan un oráculo de existencia y legibilidad de archivos para archivos YAML. Este problema está corregido en la versión 43.5.6.","source":"nvd"}],"published":"2026-07-28T22:25:29.000Z","modified":"2026-10-23T23:10:00.157Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":6.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":6.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"}],"cwes":["CWE-22","CWE-200"],"affected":[{"ranges":[{"version":">= 43.0.0, < 43.5.6","status":"affected"}],"vendor":"ddnexus","product":"pagy","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"43.0.0","status":"affected","fixed":"43.5.6"}],"ecosystem":"RubyGems","package":"pagy","purl":"pkg:gem/pagy","source":"ghsa"}],"references":[{"url":"https://github.com/ddnexus/pagy/security/advisories/GHSA-2xmw-f8j8-wfxc","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ddnexus/pagy/pull/908","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ddnexus/pagy/commit/efcf09690e9fa7d7abdfb987b785a55f87e287df","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ddnexus/pagy/releases/tag/43.5.6","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ddnexus/pagy","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-07-29T13:06:55.587Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-54659","url":"https://www.cve.org/CVERecord?id=CVE-2026-54659","licence":"CVE Terms of Use","modified":"2026-07-29T13:06:59.870Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2xmw-f8j8-wfxc","url":"https://github.com/advisories/GHSA-2xmw-f8j8-wfxc","licence":"CC-BY-4.0","modified":"2026-07-28T22:41:45.721Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-54659","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-54659","licence":"Public domain","modified":"2026-10-23T23:10:00.157Z"}],"updatedAt":"2026-11-25T22:59:30.394Z","epss":{"score":0.00369,"percentile":0.32763,"date":"2026-12-01T12:00:22.000Z"}}