Repository navigation
Add CVE-2026-132825 "Ruby2Shell" detection (Ruby interpreter, seven advisories) - #15
diptendukar wants to merge 1 commit into
Conversation
Host detectors for the seven Ruby interpreter advisories fixed in Ruby 4.0.10, 3.4.13 and 3.3.14 (2026-11-18): CVE-2026-132825, the string case-conversion heap overflow, and six siblings in case conversion and the regular expression engine. - linux/detect-ruby2shell.sh: reads the running interpreter's version from libruby, checks package backports, and reports CVE-2026-132825 as impacted when the application mounts Rack::MethodOverride (Rails unless api_only, classic Sinatra), enables Rodauth create_account, or has an affected encoding module loaded. Containers are read through /proc/PID/root. Only running Rubies decide the verdict; --count-installed counts idle ones. - windows/Detect-Ruby2Shell.ps1: the same decisions for Windows. - SSH, Ansible, DaemonSet, kubectl exec and PowerShell remoting wrappers. - Test harnesses and CI workflows (Ubuntu with Docker, host Ruby on Ubuntu and macOS, Windows). Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
|
Superseded by #16 (same files, opened from work account). |
| metadata: | ||
| labels: | ||
| app: ruby2shell | ||
| spec: |
There was a problem hiding this comment.
🔵 Low severity issue identified in your code:
The ruby2shell pod has no runAsNonRoot requirement, so its privileged detect container can run as root. With hostPID: true and one pod per node, a compromised image or script could access host processes and attempt node compromise across the cluster.
More details about this
spec defines the ruby2shell DaemonSet pod without a pod-level securityContext, and the detect container does not set runAsNonRoot. As a result, the container can run its shell and detect-ruby2shell.sh as UID 0; this is especially sensitive because detect is also privileged: true and the pod uses hostPID: true.
A plausible attack is:
- An attacker compromises the
debian:stable-slimimage, the ConfigMap-mounteddetect-ruby2shell.sh, or a process that can modify the DaemonSet. - When
ruby2shellrolls out, the attacker-controlled command runs inside thedetectcontainer as root because no non-root requirement is present. - The payload can inspect host processes through the shared PID namespace, for example with
ps -ef, and use its privileged container context to access host devices or attempt a container escape. - Because this is a DaemonSet, the same root-capable
detectworkload runs on every Linux node, turning one compromised deployment into node-wide and potentially cluster-wide access.
The finding is at the DaemonSet pod spec; the existing privileged: true setting increases the impact but does not establish that the workload runs as a non-root user.
To resolve this comment:
✨ Commit fix suggestion
| spec: | |
| spec: | |
| securityContext: | |
| runAsNonRoot: true #: |
View step-by-step instructions
-
Add a pod-level
securityContextunderspec.template.specso every container must run as a non-root user:spec: template: spec: securityContext: runAsNonRoot: true runAsUser: 101 runAsGroup: 101 fsGroup: 101 seccompProfile: type: RuntimeDefault
-
Ensure the
debian:stable-slimimage and the mounted files allow UID101to run/bin/sh,bash, and the detector script. Use a purpose-built non-root image if the current image requires root. -
Keep
privileged: trueonly if the detector requires host-level access. A non-root security context limits the process user, butprivilegedstill grants extensive capabilities.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by run-as-non-root.
You can view more details about this finding in the Semgrep AppSec Platform.
| labels: | ||
| app: ruby2shell | ||
| spec: | ||
| hostPID: true |
There was a problem hiding this comment.
🟡 Medium severity issue identified in your code:
The privileged detect container shares the node’s PID namespace, allowing compromised code to enumerate and ptrace host or other-pod processes. An attacker could extract secrets or execute code with a target process’s privileges.
More details about this
ruby2shell sets spec.hostPID: true, so each privileged detect container shares the node’s process-ID namespace instead of seeing only its own processes. Because the container is also configured with securityContext.privileged: true, code running inside it can target processes from other pods and the host; the script’s stated purpose of reporting Rubies in other pods confirms that cross-container process visibility is intentional.
A plausible attack:
- An attacker gains command execution in the
detectcontainer, for example through a compromised ConfigMap script or access to the DaemonSet’s container. - The attacker uses the shared PID namespace to enumerate host and other-pod processes with commands such as
ps -efand identifies a long-running service process. - The attacker attaches to that process with
ptrace(for example,strace -p <pid>or a custom injector), using the container’s privileged capabilities to inspect memory or execute code in the target process. - The attacker extracts credentials, tokens, or application data from the target, or runs code with the target’s host-side privileges, potentially moving from the container into control of the node and workloads scheduled there.
This setting therefore turns compromise of the detect container into a path for observing and interacting with processes that belong to the node and unrelated pods.
To resolve this comment:
✨ Commit fix suggestion
-
Remove
hostPID: truefrom the pod template. -
Update
detect-ruby2shell.shso it does not inspect host or other pod processes through/proc. A pod without host PID access can only see its own process namespace. -
If node-wide process visibility is required, redesign the detector to use a dedicated, approved node-level monitoring mechanism instead of sharing the host PID namespace, such as a node agent that exposes only the required data through an authenticated interface.
-
Keep the detector container unprivileged unless a separate, documented requirement needs elevated permissions; remove
privileged: truewhen it is not required.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by hostpid-pod.
You can view more details about this finding in the Semgrep AppSec Platform.
| containers: | ||
| - name: detect | ||
| image: debian:stable-slim | ||
| securityContext: |
There was a problem hiding this comment.
🟡 Medium severity issue identified in your code:
The detect container runs privileged on every Linux node but does not disable privilege escalation. A compromise of the image or mounted detection script could expose host processes and provide a path to node-level access.
More details about this
The detect container in the ruby2shell DaemonSet declares securityContext, but it only sets privileged: true; it does not set allowPrivilegeEscalation: false. Because this DaemonSet runs one debian:stable-slim container on every Linux node, a shell obtained through the image, /scripts/detect-ruby2shell.sh, or a process exposed by the application can retain elevated privileges and use the container’s privileged capabilities. hostPID: true also places that shell in the node’s process namespace, exposing host processes and making actions against them possible.
A plausible attack is:
- An attacker gains code execution in
detect, for example through a compromiseddebian:stable-slimimage or a malicious command/configuration delivered through the mounteddetectConfigMap. - They run
kubectl -n ruby2shell exec <pod> -- /bin/shand execute commands as the container’s privileged user. - Since
allowPrivilegeEscalationis not disabled andprivileged: truegrants broad Linux capabilities and device access, the attacker can inspect or interfere with node processes through the shared PID namespace, then use available host devices or kernel attack surface to escape the container and access node-level resources. - Because this is a DaemonSet, the same compromise is deployed across every matching Linux node, allowing the attacker to repeat the attack and expand access across the cluster.
To resolve this comment:
✨ Commit fix suggestion
| securityContext: | |
| securityContext: | |
| allowPrivilegeEscalation: false #: |
View step-by-step instructions
-
Remove
privileged: truefrom thedetectcontainer, or set it tofalse. A privileged container cannot safely useallowPrivilegeEscalation: false. -
Set the container security context explicitly:
securityContext: privileged: false allowPrivilegeEscalation: false
-
If the detector currently depends on privileged access, change it to use only the specific capabilities, host paths, or Kubernetes permissions it requires instead of enabling full container privilege. Keep
hostPID: trueonly if it is strictly required. -
Keep the security context at the container level, directly under the container’s
imageand alongside the other container properties.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by allow-privilege-escalation.
You can view more details about this finding in the Semgrep AppSec Platform.
What this adds
A new incident directory,
CVE-2026-132825/, with host detectors for the sevenmemory-safety bugs fixed in Ruby 4.0.10, 3.4.13 and 3.3.14 on 2026-11-18:
CVE-2026-132825 (GHSA-34m4-m9fh-gqp5, "Ruby2Shell", the string case-conversion
heap overflow) and six sibling advisories that have GHSA IDs only so far.
linux/detect-ruby2shell.shlinux/ssh-ruby2shell.sh,ansible-ruby2shell.yml,k8s-ruby2shell.yaml,k8s-exec-ruby2shell.shwindows/Detect-Ruby2Shell.ps1,remote-ruby2shell.ps1linux/tests/,windows/tests/.github/workflows/ruby2shell-*.ymlSame contract as the other detectors: one block per instance,
[!]/OK/[?]/n/amarkers, last lineimpacted | not impacted | unknown, exit0 / 1 / 2 / 3.How it decides
on the Ruby that is running. The version is read from the
ruby X.Y.Z (banner inside the process's own
libruby, without executing anything. Apatched and an unpatched Ruby return identical results for every input and
the fix leaves no marker in the binary, so there is nothing to probe.
Distribution packages are checked through the package changelog (dpkg, rpm).
[!]on an unpatched Ruby when the applicationmounts
Rack::MethodOverride(Rails unlessapi_only, classic-styleSinatra, or an explicit
use), enables Rodauth'screate_accountwithlogin confirmation, or the process has one of the 14 affected encoding
modules loaded. We confirmed the MethodOverride and Rodauth paths at
runtime with benign instrumentation: a multipart part's declared charset
survives into the case-conversion call, before authentication.
compiled from user input), so they stay
[?]on an unpatched Ruby. Arunning unpatched Ruby is therefore never
not impacted.disk (macOS ships 2.6 in
/usr/bin), so installed-but-not-runninginterpreters are listed with
=> not counted.--count-installed/-CountInstalledcounts them. The README states the blind spot (anythingnot running during the scan).
/proc/PID/root: nothing is started inside acontainer and the DaemonSet needs no
nsenter.Testing
linux/tests/run-tests.sh(officialruby3.4.12 and 3.4.13 images, pinnedby digest): 20/20 passed locally before the final review changes. It has
NOT been re-run since those changes and five cases were added afterwards;
CI on this PR is its first run in that state.
linux/tests/run-tests-host.sh(no Docker, uses the host's own unpatchedRuby): 20/20 under WSL Ubuntu 22.04 with the distribution's Ruby 3.0.2,
which also exercises the dpkg backport path.
windows/tests/Run-Tests.ps1(stand-inruby.exebuilt fromFakeRuby.cs): 24/24 under Windows PowerShell 5.1.Not verified, please look at these in review:
psandlsofinstead of/proc) has never run ona Mac. The
test-macosjob is its first test.or Kubernetes cluster was used. The DaemonSet approach was exercised as a
privileged sidecar container sharing another container's PID namespace.
remoting.
CVE" branch of the backport check has only been read, not observed.
Sources
d582f8f13d700d8e39714d3a8f11eb4bd2bc69f0🤖 Generated with Claude Code