
Proof-of-concept and differential lab for CVE-2026-107360, a rubygem-safemode compound-assignment Jail allow-list bypass enabling arbitrary no-arg method calls in Foreman/Satellite templates.
| CVE | CVE-2026-107360 |
| Component | rubygem-safemode — sandboxed template evaluator (lib/safemode/parser.rb), as used by Foreman and Red Hat Satellite 6 |
| Affected | Every released safemode version through 2.0.3 (tag edc74ce); Red Hat Satellite 6.16, 6.17, 6.18 (rubygem-safemode 1.5.0-1/1.5.0-2) |
| Fixed in | Upstream PR #75 (commits ca7d4e5, 0bd3998, branch fix/cve-2026-107360), not yet merged to master; Red Hat package rubygem-safemode 1.5.0-3.el8sat / 1.5.0-3.el9sat (RHSA-2026:99949/99950/99952) |
| CWE | CWE-183 (Permissive List of Allowed Inputs); classified CWE-265 by VulDB |
| Impact | Arbitrary no-argument method invocation on objects exposed to the template renderer without Jail allow-list mediation (host deletion, host reboot), unmediated attribute and indexed setters, disclosure of non-allow-listed object state |
| Vector | Authenticated low-privilege user supplying ERB template content rendered by Foreman/Satellite with safemode_render enabled |
| Trigger | Any compound assignment whose getter or setter is not allow-listed: `@host.destroy |
| Credit | Kaya Emre Arikan, via Red Hat Product Security (Bugzilla 2547645) |
Compound assignment expressions in safemode-sandboxed template code are evaluated
without mediating method calls through the Jail allow-list. The parser allowlist in
safemode 2.0.3 admits the op_asgn/safe_op_asgn sexp node family while providing no
handling for them, so Ruby2Ruby emits the assignment literally: the getter and the
setter are invoked by assignment syntax on the raw receiver — an instance variable
resolved directly on the Safemode::Scope — and never pass through the call nodes
where safemode inserts .to_jail. An authenticated user who can supply template
content therefore invokes any zero-argument method on any template object, executes
any setter, and reads back any attribute the renderer exposes, regardless of the
Jail allow-list. Foreman renders provisioning templates, partition tables, report
templates and job templates exactly this way; the proof-of-concept in this repository
deletes a probe host object and extracts a non-allow-listed secret attribute through
the sandbox.
safemode rewrites sandboxed Ruby source before evaluation: the source is parsed with
Prism (Prism::Translation::RubyParser), every call node gets .to_jail inserted on
its receiver by Safemode::Parser#process_call, and the rewritten tree is emitted back
to Ruby source by Ruby2Ruby and evaluated inside a Safemode::Scope binding.
In safemode 2.0.3, the parser's static node allowlist explicitly admits the compound
assignment node family while its own comment records the consequence
(lib/safemode/parser.rb:93-96):
# NOTE: op_asgn*/safe_op_asgn* do not insert .to_jail on the
# receiver. Setters are called directly on the real object, bypassing Jail.
:op_asgn, :op_asgn1, :op_asgn2, :op_asgn_and, :op_asgn_or,
:safe_op_asgn, :safe_op_asgn2,
None of these node types has a process_* handler in 2.0.3, so they fall through to
Ruby2Ruby's default processing and are emitted verbatim. The sexp shapes on
ruby 3.1.7 / prism 1.9.0 (evidence/sexp-dump-vulnerable.txt) show why the bypass is
complete: the receiver is an ivar node, not a call node, and the method invocation
is implicit in the assignment syntax.
"@probe.dest ||= nil" -> s(:op_asgn2, s(:ivar, :@probe), :dest=, :"||", s(:nil))
"@probe&.dest ||= nil" -> s(:safe_op_asgn2, s(:ivar, :@probe), :dest=, :"||", s(:nil))
"@probe[0] ||= 1" -> s(:op_asgn1, s(:ivar, :@probe), s(:arglist, s(:lit, 0)), :"||", s(:lit, 1))
Safemode::Scope resolves @probe as the real object (Scope#initialize assigns
@probe = instance_vars[:probe]). The emitted code is the literal assignment, so:
@host.destroy ||= nil evaluates destroy on the real Host object — any
zero-argument method name works as the getter, allow-listed or not;@host.audit ||= 1) reaches the setter audit= on the real object;@host[0] ||= 1 invokes both [] and []= on the real object;@host.secret ||= nil
returns non-allow-listed object state to the template.Plain assignments are not exploitable: attrasgn/safe_attrasgn were removed from the
allowlist by commit e963aab ("Reject unreviewed parser nodes", safemode 2.0.3) and
raise Safemode::SecurityError at rewrite time. The compound-assignment family is the
only gate left open.
The upstream fix (PR #75) moves op_asgn, op_asgn1 and op_asgn2 (and their
safe-navigation forms) out of the static allowlist into explicit handlers
(lib/safemode/parser.rb:159-205 on fix/cve-2026-107360):
LOGICAL_ASSIGNMENT_OPERATORS = [:"||", :"&&"].freeze
def process_op_asgn2(exp)
return raise_security_error(:op_asgn2, super(exp)) unless LOGICAL_ASSIGNMENT_OPERATORS.include?(exp[3])
_, receiver, name, operator, rhs = exp
process_logical_attribute_assignment(receiver, name, operator, rhs)
end
def process_logical_attribute_assignment(receiver, name, operator, rhs, safe_call = false)
receiver = jail(process_call_receiver(receiver), safe_call: safe_call)
name = name.to_s.sub(/=$/, "")
dot = safe_call ? "&." : "."
"#{receiver}#{dot}#{name} #{operator}= #{process rhs}"
end
Compound assignments with an arithmetic operator (+=, -=, …) raise
Safemode::SecurityError before template execution; logical assignments (||=,
&&=) are rewritten with .to_jail on the receiver, so getter and setter are both
mediated by the Jail and must both be allow-listed.
One target image, two builds. The vulnerable and fixed sides differ only in the checked-out safemode tree; base image, dependency set, service, entrypoint and configuration are identical.
| Container | Image | safemode ref | Port | Bounds |
|---|---|---|---|---|
cve107360-vuln | cve-2026-107360:vuln | tag v2.0.3 (edc74ce) | 28081 | --cpus 2 --memory 4g |
cve107360-fixed | cve-2026-107360:fixed | PR #75 head 0bd3998 | 28082 | --cpus 2 --memory 4g |
| PoC runner | cve-2026-107360-poc:local | — | — | python:3.12-alpine |
Network: dedicated Podman network cve2026107360lab.
Versions resolved at build time (evidence/versions.txt), identical on both sides:
| Component | Version |
|---|---|
| Ruby | 3.1.7p261 (x86_64-linux-musl) |
| safemode | 2.0.3 (both sides; the fixed side carries the PR #75 parser) |
| prism | 1.9.0 |
| ruby2ruby | 2.5.2 |
| ruby_parser | 3.21.1 |
| sexp_processor | 4.17.4 |
The service (lab/service/app.rb) reproduces Foreman's rendering path: template
source → Safemode::Parser.jail (parse + rewrite) → Kernel.eval in a
Safemode::Scope binding with the template assigns. The probe Host object exposes
name and status through its Jail allow-list; destroy, reboot, secret,
audit, audit= and the indexed accessors are deliberately not allow-listed, and
every real invocation of them is recorded in a side-effect registry the sandbox cannot
touch. The registry is the observer: a recorded call proves the method executed on the
real object, not through the Jail.
make build # builds both target images and the PoC runner
make run # starts both containers on the lab network
make poc-vuln MODE=check
make poc-fixed MODE=exploit
make sweep-vuln # behavioral 0day sweep on the vulnerable build
make sweep-fixed # behavioral 0day sweep on the fixed build
make evidence # recaptures everything in evidence/
make down