Skip to content

Stored XSS in SelectView via Missing Server-Side Option Validation

Moderate
tvdeyen published GHSA-7m8w-vg9p-qjr6 Jul 22, 2026

Package

bundler alchemy_cms (RubyGems)

Affected versions

< 8.3.5
< 8.2.9
< 8.1.15
< 8.0.16

Patched versions

8.3.5
8.2.9
8.1.15
8.0.16

Description

Summary

Alchemy::Ingredients::SelectView#call delegates to super (i.e., Alchemy::Ingredients::BaseView#call) for the single-value path, which returns value.html_safe. The allowed option list (select_values) defined in elements.yml is enforced only in the admin UI dropdown; no server-side validation checks that a submitted value belongs to the allowed set. An authenticated CMS author can bypass the dropdown by sending a direct API request with an arbitrary HTML string as the ingredient value. That string is stored verbatim and rendered unescaped into the published public page, executing in every visitor's browser.

Details

Root cause

The call chain for a single-select ingredient at render time is:

SelectView#call
  └─ (ingredient.multiple? is false) → super
       └─ BaseView#call → value.html_safe
# app/components/alchemy/ingredients/select_view.rb, lines 4–11
def call
  if ingredient.multiple? && value.is_a?(Array)
    value.to_sentence
  else
    super   # delegates to BaseView#call
  end
end
# app/components/alchemy/ingredients/base_view.rb, lines 18–20
def call
  value.html_safe   # trusts the stored string unconditionally
end

value is the raw string stored in alchemy_ingredients.value via the admin elements API. The allowed values list is defined in elements.yml under select_values and rendered as a <select> dropdown in the admin UI. This constraint is applied only client-side; the API endpoint (PATCH /admin/elements/:id) accepts any string in element[ingredients_attributes][N][value] without checking it against the YAML definition.

No validation exists in the Alchemy::Ingredients::Select model:

# app/models/alchemy/ingredients/select.rb
allow_settings %i[allow_clear display_inline select_values multiple]
# No validates :value, inclusion: { in: ... }

Because value.html_safe is returned by BaseView#call, Rails' default HTML escaping is suppressed and the raw stored string appears in the public page inside whatever wrapper the template provides (here <div class="select">…</div>).

PoC

  1. Store CSRF token

imaged

  1. Create XSS Payload
image
  1. Publish the page.
  2. Browse to the page and observe the XSS Popped
image

Impact

Any authenticated CMS user with author role or above can plant persistent JavaScript in a select ingredient by bypassing the client-side option list. The payload executes in every anonymous visitor's browser when the published page loads. The absence of server-side validation is a systemic issue: the entire security model for the select ingredient's allowed values relies on the browser never sending an out-of-list submission. A trivial curl command defeats this. Combined with BaseView#call returning value.html_safe, the path from authorship to XSS requires no privilege escalation beyond the author role. Attack surface: session hijacking, phishing overlays, drive-by malware delivery, defacement.

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N

CVE ID

No known CVE

Weaknesses

Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. Learn more on MITRE.

Credits