# Possible XSS Vulnerability in Action Controller

Action Controller's translate helper marks I18n error messages and _html default values as html_safe, enabling reflected XSS via untrusted keys or defaults rendered in views.

- Payout: $1,068
- Severity: low
- Program: Internet Bug Bounty
- Found by: ooooooo_q
- Disclosed: 2024-09-25
- CVE: CVE-2024-26143
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/2520694
- Library page: https://bugbountylibrary.com/r/h1%3A2520694
- Tags: area:web domain:web impact:integrity kind:bounty platform:hackerone sev:low tech:ruby technique:incomplete-fix technique:regression technique:source-review vuln:xss

**Target:** Rails Action Controller translate/t helper (abstract_controller/translation.rb)
**Root cause:** Action Controller's translate marks I18n error messages (containing the key) and _html-suffixed default values as html_safe, unlike Action View which escapes them; this is CVE-2024-26143, a separate vulnerability in Action Controller.
**Steps:**
1. Create Rails 7.1.3.1 app; add route `get "/articles/missing_key", to: "articles#missing_key"` and `get "/articles/default", to: "articles#default"`.
2. Controller: `@message = t(params[:text])` and `@message = t("message_html", default: "<script>alert(location)</script>")`.
3. View: `<h1><%= @message %></h1>`.
4. Request `GET /articles/missing_key?text=%3Cscript%3Ealert(location)%3C/script%3E_html` — I18n missing-key error embeds key and is html_safe.
5. Request `GET /articles/default` — default value rendered unescaped due to _html suffix.
**How found:** Compared Action Controller's translate implementation against Action View's, noticed Action View escapes but controller marks output html_safe; recalled the Action Controller translation helper advisory, then tested both the missing-key error path and the _html default path.
**Exploitation:** Attacker controls a param passed as translation key ending in _html (or a default value); the resulting html_safe string is rendered in a view, executing script in victim's browser.
**Insight:** When a framework has parallel implementations of the same helper (controller vs view), check whether security fixes were ported to both; I18n missing-key error messages embed the attacker-controlled key and may be marked html_safe.

