Scanner and proof-of-concept exploit for Apache Struts 2 CVE-2013-2251 (S2-016) OGNL injection, detecting and exploiting unauthenticated remote code execution via action/redirect prefixes.
Apache Struts 2 - DefaultActionMapper Prefixes OGNL Code Execution (S2-016)
| field | value |
|---|---|
| CVE | CVE-2013-2251 |
| severity | critical |
| CVSS | 9.3 (record; CVSS:2.0 AV:N/AC:M/Au:N/C:C/I:C/A:C); NVD also lists CVSS:3.1 9.8 |
| fixed in | Struts 2.3.15.1 (affected: 2.0.0 through 2.3.15) |
| class | OGNL injection leading to RCE (CWE-20 per template, CWE-74 per NVD) |
| scanner version | 1.0.0 |
| python | 3.8+ stdlib only, no third-party deps |
If you want the exploit, find it here: https://satoshidisk.com/pay/CT5RSZ
In Struts 2.0.0 through 2.3.15 the text following the action:,
redirect: or redirectAction: parameter prefixes of
com.opensymphony.xwork2.DefaultActionMapper is not sanitized and is
evaluated as an OGNL expression against the value stack. One request
therefore gives unauthenticated code execution: the template payload
builds a ProcessBuilder for sh -c id, reads its stdout and prints it
through the HttpServletResponse writer, so the body of /index.action
or /login.action comes back carrying the uid=... gid=... groups=...
line. The 2.3.15.1 patch (visible in the vendor source diff) drops the
redirect: and redirectAction: prefix registrations from the mapper's
prefix trie, leaving only method: and action:.
DefaultActionMapper.getMapping() walks the request parameter names
through a prefix trie in handleSpecialParameters(). In 2.3.15 the trie
holds four parameter actions: method: sets the method, action: sets
the action name, and redirect: / redirectAction: build a
ServletRedirectResult whose location string is later parsed with
OgnlUtil (conditionalParse), i.e. the raw value after the prefix is
handed to the OGNL engine and evaluated against the value stack. That
evaluation is the injection point: the whole expression after : is
attacker controlled, and OGNL in this line has unrestricted access to
#context, so new java.lang.ProcessBuilder(...).start() plus the
response writer yields direct, in-band RCE with no auth and no CSRF
token dependency. NVD records it as CWE-74 (template classification
CWE-20), CVSS v2 9.3 with NVD's v3.1 restated at 9.8, and CISA KEV
since 2022-03-25. Remediation per the vendor: upgrade to Struts
2.3.15.1 or later, where only the method: and action: prefixes
remain and their values go through cleanupActionName().
http/cves/2013/CVE-2013-2251.yaml
exactly: max-request: 9 = 3 raw request shapes x 3 prefix payloads.GET /index.action?{prefix}=${...id...},
GET /login.action?{prefix}=${...id...} and
GET /index.action?{prefix}%3A%24%7B...%7D (the
denyMethodExecution=false + allowStaticMethodAccess variant).redirect, action, redirectAction.((u|g)id|groups)=[0-9]{1,4}\([a-z0-9]+\) and status code in
{200, 400} (or). check(url) is True when any of the 9 combinations
satisfies both.HTTPError bodies
are read because 400 is an accepted matcher status.urls.txt (tagger output such as
host:8080/path) are auto-prefixed with http://.status, hit, matched (the regex
group) and a 200-char snippet, plus request_count (9), so a row is
auditable offline from result_b64.# scanner: streamed CSV + optional JSON sidecar
python scanner/CVE-2013-2251/scanner.py urls.txt 8 CVE-2013-2251.csv --json CVE-2013-2251.json
# exploit: result dict + optional CSV/JSON dumps
python exploit/CVE-2013-2251/exploit.py http://target:8080 --csv CVE-2013-2251.csv --json CVE-2013-2251.json --verbose
urls.txt is a plain file, one target per line, # for comments.
[*] Apache Struts 2 CVE-2013-2251 scanner (S2-016 action:/redirect:/redirectAction: OGNL)
scanner : CVE-2013-2251 v1.0.0
threads : 8 | csv: CVE-2013-2251.csv | json: CVE-2013-2251.json
[*] Apache Struts 2 CVE-2013-2251 scanner (S2-016 action:/redirect:/redirectAction: OGNL)
[2026-12-03 11:37:11] loaded 2 target(s) from urls.txt
[2026-12-03 11:37:12] [1/2] http://struts-host:8080 -> VULNERABLE
[2026-12-03 11:37:12] [2/2] http://other-host:8080 -> not-vuln
[2026-12-03 11:37:12] summary: total=2 vulnerable=1 not-vuln=1 errors=0
[2026-12-03 11:37:12] timing : avg=640ms max=910ms wall=1.28s
[2026-12-03 11:37:12] report saved: CVE-2013-2251.csv
| column | meaning |
|---|---|
| n | 1-based row number |
| url | target as provided |
| status | ok / error |
| vulnerable | verdict |
| elapsed_ms | per-target timing |
| token | 12-char md5 over the row details |
| result_b64 | base64(JSON) full details |
scanner.py - detection only, stdlib, streamed CSV + JSON sidecar.README.md - this file.DESCRIPTION.md - deeper technical notes.../../exploit/CVE-2013-2251/exploit.py - two-stage POC.| code | meaning |
|---|---|
| 0 | at least one target answered |
| 2 | every target errored |