Skip to content

Commit fd59fa9

Browse files
committed
v0.8.0: API2/API6 breadth + CSWSH
Three new endpoint checks (registered in AllChecks) completing OWASP API breadth: - SensitiveFlowCheck (API6) — SCHEMA-STATIC: flags high-value mutations (refund/transfer/payout/invite/grant/delete/…) for manual business-logic review; prefix match catches compound names. Sends nothing. - UserEnumerationCheck (API2) — CONFIG-GATED: operator supplies valid + invalid identifiers (new CheckConfig fields + per-target Config-tab inputs); sends two dummy-password login probes and reports a response differential (error templates with identifiers stripped, + data presence). Inert without config. - CswshCheck (API8) — opens the subscription WS upgrade with a foreign Origin via api.websockets().createWebSocket(); SUCCESS ⇒ CSWSH, then closes the socket. Gated on the schema advertising a subscription type. One socket, no messages. Supporting: Heuristics SENSITIVE_FLOW/isSensitiveFlow (prefix), IDENTIFIER_ARG/ isIdentifierArg; CheckConfig userEnumValid/userEnumInvalid + hasUserEnumConfig. Totals: 32 endpoint checks + per-operation scanner, spanning OWASP API1–API9. Tests: 127 total (+7) via mocks (no real WS/network), all green. README updated. Version 0.8.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KCnJ6A5Giijp63qk3TYj3J
1 parent 51e8b11 commit fd59fa9

11 files changed

Lines changed: 390 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ On load the Output tab logs:
8787
| Auth brute-force amplification | API2:2023 | schema-static: batchable auth operations (rate-limit bypass) |
8888
| CORS misconfiguration | API8:2023 | reflected Origin + credentials (credentialed cross-origin read) |
8989
| BFLA (per-operation, incl. mutations) | API5:2023 | privileged op resolves for the low-priv identity (operation scan) |
90+
| Sensitive business flows | API6:2023 | schema-static: high-value mutations flagged for manual review |
91+
| User enumeration | API2:2023 | config-gated: valid vs invalid identifier login differential |
92+
| CSWSH (subscriptions) | API8:2023 | cross-origin WebSocket handshake accepted |
9093

9194
## Active out-of-band checks (Burp Collaborator)
9295

‎build.gradle.kts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66

77
group = "com.redcell"
88
// Overridable for releases: -PreleaseVersion=0.2.0 (CI tags strip the leading "v").
9-
version = (findProperty("releaseVersion") as String?)?.takeIf { it.isNotBlank() } ?: "0.7.0"
9+
version = (findProperty("releaseVersion") as String?)?.takeIf { it.isNotBlank() } ?: "0.8.0"
1010

1111
repositories {
1212
mavenCentral()

‎src/main/kotlin/com/redcell/gqlanalyzer/GraphQLAnalyzer.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ class GraphQLAnalyzer : BurpExtension {
3636

3737
companion object {
3838
const val EXTENSION_NAME = "GraphQL OWASP-API Analyzer"
39-
const val VERSION = "0.7.0"
39+
const val VERSION = "0.8.0"
4040
}
4141
}

‎src/main/kotlin/com/redcell/gqlanalyzer/checks/AllChecks.kt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.redcell.gqlanalyzer.checks.impl.CircularFragmentCheck
1111
import com.redcell.gqlanalyzer.checks.impl.ContentTypeBypassCheck
1212
import com.redcell.gqlanalyzer.checks.impl.CorsCheck
1313
import com.redcell.gqlanalyzer.checks.impl.CsrfCheck
14+
import com.redcell.gqlanalyzer.checks.impl.CswshCheck
1415
import com.redcell.gqlanalyzer.checks.impl.DeferStreamCheck
1516
import com.redcell.gqlanalyzer.checks.impl.DeprecatedFieldInventoryCheck
1617
import com.redcell.gqlanalyzer.checks.impl.DepthComplexityCheck
@@ -25,6 +26,8 @@ import com.redcell.gqlanalyzer.checks.impl.InjectionSeederCheck
2526
import com.redcell.gqlanalyzer.checks.impl.IntrospectionCheck
2627
import com.redcell.gqlanalyzer.checks.impl.MassAssignmentCheck
2728
import com.redcell.gqlanalyzer.checks.impl.OobCanaryInjectionCheck
29+
import com.redcell.gqlanalyzer.checks.impl.SensitiveFlowCheck
30+
import com.redcell.gqlanalyzer.checks.impl.UserEnumerationCheck
2831
import com.redcell.gqlanalyzer.checks.impl.PaginationAbuseCheck
2932
import com.redcell.gqlanalyzer.checks.impl.SsrfSeederCheck
3033
import com.redcell.gqlanalyzer.checks.impl.TracingExtensionsCheck
@@ -69,5 +72,9 @@ object AllChecks {
6972
IdorEnumerationCheck(),
7073
AuthAmplificationCheck(),
7174
CorsCheck(),
75+
// v0.8.0 — API2/API6 breadth + CSWSH
76+
SensitiveFlowCheck(),
77+
UserEnumerationCheck(),
78+
CswshCheck(),
7279
)
7380
}

‎src/main/kotlin/com/redcell/gqlanalyzer/checks/Heuristics.kt‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,27 @@ object Heuristics {
182182

183183
fun isAuthField(name: String) = norm(name) in AUTH_FIELD
184184

185+
/** Arg names that carry a user identifier (for user-enumeration probing). */
186+
val IDENTIFIER_ARG = setOf("username", "email", "user", "login", "identifier", "account", "emailaddress", "handle")
187+
188+
fun isIdentifierArg(name: String) = norm(name) in IDENTIFIER_ARG
189+
190+
// ---- business-critical flows (API6) ----
191+
192+
/** Mutation names that drive sensitive business flows warranting manual review. */
193+
val SENSITIVE_FLOW = setOf(
194+
"purchase", "buy", "checkout", "order", "placeorder", "pay", "payment", "transfer",
195+
"withdraw", "deposit", "refund", "payout", "charge", "wire", "redeem", "invite",
196+
"grant", "promote", "approve", "subscribe", "unsubscribe", "cancel", "delete",
197+
"remove", "sendmoney", "sendinvite", "addfunds", "changerole", "setrole", "impersonate",
198+
)
199+
200+
// Prefix match so compound names (refundOrder, deleteUser, transferFunds) are caught.
201+
fun isSensitiveFlow(name: String): Boolean {
202+
val n = norm(name)
203+
return SENSITIVE_FLOW.any { n == it || n.startsWith(it) }
204+
}
205+
185206
// ---- CORS misconfiguration (API8) ----
186207

187208
/**
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.redcell.gqlanalyzer.checks.impl
2+
3+
import burp.api.montoya.websocket.extension.ExtensionWebSocketCreationStatus
4+
import com.redcell.gqlanalyzer.checks.GraphQLCheck
5+
import com.redcell.gqlanalyzer.model.CheckContext
6+
import com.redcell.gqlanalyzer.model.Confidence
7+
import com.redcell.gqlanalyzer.model.Finding
8+
import com.redcell.gqlanalyzer.model.Severity
9+
10+
/**
11+
* API8:2023 — Cross-Site WebSocket Hijacking (CSWSH) on GraphQL subscriptions. Opens
12+
* the WebSocket upgrade with a foreign `Origin`; if the handshake completes anyway the
13+
* server does not validate Origin, so a malicious page can open an authenticated
14+
* subscription in a victim's browser (cookie auth). Gated on the schema advertising a
15+
* subscription type. One socket, no messages — closed immediately; non-destructive.
16+
*/
17+
class CswshCheck : GraphQLCheck {
18+
override val id = "cswsh"
19+
override val owaspId = "API8:2023"
20+
21+
override fun run(ctx: CheckContext): List<Finding> {
22+
val schema = ctx.schema ?: return emptyList()
23+
if (schema.subscriptionTypeName == null) return emptyList()
24+
25+
val path = ctx.request.path().substringBefore('?')
26+
val wsReq = ctx.request.withMethod("GET").withPath(path).withBody("")
27+
.withUpdatedHeader("Upgrade", "websocket")
28+
.withUpdatedHeader("Connection", "Upgrade")
29+
.withUpdatedHeader("Sec-WebSocket-Version", "13")
30+
.withUpdatedHeader("Sec-WebSocket-Key", "dGhlIHNhbXBsZSBub25jZQ==")
31+
.withUpdatedHeader("Sec-WebSocket-Protocol", "graphql-transport-ws, graphql-ws")
32+
.withUpdatedHeader("Origin", TEST_ORIGIN)
33+
34+
val creation = ctx.api.websockets().createWebSocket(wsReq)
35+
creation.webSocket().ifPresent { it.close() }
36+
if (creation.status() != ExtensionWebSocketCreationStatus.SUCCESS) return emptyList()
37+
38+
return listOf(
39+
Finding(
40+
name = "GraphQL subscription CSWSH (cross-origin WebSocket handshake accepted)",
41+
detail = """
42+
The subscription WebSocket completed its upgrade handshake even with a foreign
43+
`Origin: $TEST_ORIGIN`. The server does not validate the Origin of WebSocket
44+
connections, so if sessions are cookie-based a malicious site can open an
45+
authenticated subscription in a logged-in victim's browser and read streamed data
46+
(Cross-Site WebSocket Hijacking).
47+
48+
One socket was opened with a spoofed Origin and closed immediately; no messages
49+
were exchanged. Confirm the session is cookie/ambient-credential based (token-in-
50+
header auth is not exploitable this way).
51+
52+
CVSS v3.1: AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N (6.5, Medium) — victim interaction
53+
required; confidentiality impact scales with what the subscription streams.
54+
""".trimIndent(),
55+
severity = Severity.MEDIUM,
56+
confidence = Confidence.TENTATIVE,
57+
remediation = """
58+
Validate the `Origin` header on the WebSocket upgrade against an allow-list and
59+
reject unknown origins, require a CSRF/handshake token for subscription
60+
connections, and prefer non-cookie (bearer) auth for the WebSocket transport.
61+
""".trimIndent(),
62+
),
63+
)
64+
}
65+
66+
companion object {
67+
const val TEST_ORIGIN = "https://evil.example"
68+
}
69+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.redcell.gqlanalyzer.checks.impl
2+
3+
import com.redcell.gqlanalyzer.checks.GraphQLCheck
4+
import com.redcell.gqlanalyzer.checks.Heuristics
5+
import com.redcell.gqlanalyzer.model.CheckContext
6+
import com.redcell.gqlanalyzer.model.Confidence
7+
import com.redcell.gqlanalyzer.model.Finding
8+
import com.redcell.gqlanalyzer.model.Severity
9+
10+
/**
11+
* API6:2023 (Unrestricted Access to Sensitive Business Flows). SCHEMA-STATIC: flags
12+
* mutations whose names drive high-value business flows (purchase, transfer, refund,
13+
* payout, invite, grant, delete, …) for manual review. Whether these flows have
14+
* anti-automation / rate / fraud controls is business-logic — surfaced here as
15+
* review targets, never exercised. Sends nothing.
16+
*/
17+
class SensitiveFlowCheck : GraphQLCheck {
18+
override val id = "sensitive-flow"
19+
override val owaspId = "API6:2023"
20+
21+
override fun run(ctx: CheckContext): List<Finding> {
22+
val schema = ctx.schema ?: return emptyList()
23+
val flows = schema.mutations().map { it.name }.filter { Heuristics.isSensitiveFlow(it) }.distinct()
24+
if (flows.isEmpty()) return emptyList()
25+
26+
return listOf(
27+
Finding(
28+
name = "GraphQL sensitive business flows exposed (${flows.size})",
29+
detail = """
30+
Mutations driving high-value business flows are exposed and warrant manual review
31+
for unrestricted access (API6): ${flows.joinToString(", ")}.
32+
Confirm each enforces anti-automation (rate limiting, CAPTCHA, device/velocity
33+
checks), server-side authorization, and business invariants (e.g. balance/ownership
34+
checks) — not just input validation.
35+
36+
Detected statically from the schema; no mutation was invoked.
37+
38+
CVSS v3.1: not scored — business-logic review guidance; impact depends on the flow
39+
(payment/transfer/role-change are typically High).
40+
""".trimIndent(),
41+
severity = Severity.INFORMATION,
42+
confidence = Confidence.TENTATIVE,
43+
remediation = """
44+
Protect sensitive flows with anti-automation and abuse controls (rate/velocity
45+
limits, CAPTCHA/step-up where appropriate), enforce authorization and business
46+
invariants server-side, and monitor for anomalous volumes per principal.
47+
""".trimIndent(),
48+
),
49+
)
50+
}
51+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package com.redcell.gqlanalyzer.checks.impl
2+
3+
import com.redcell.gqlanalyzer.checks.GraphQLCheck
4+
import com.redcell.gqlanalyzer.checks.Heuristics
5+
import com.redcell.gqlanalyzer.model.CheckContext
6+
import com.redcell.gqlanalyzer.model.Confidence
7+
import com.redcell.gqlanalyzer.model.Finding
8+
import com.redcell.gqlanalyzer.model.Severity
9+
import com.redcell.gqlanalyzer.transport.GraphQLHttp
10+
import com.redcell.gqlanalyzer.transport.QueryBuilder
11+
12+
/**
13+
* API2:2023 — username/account enumeration. CONFIG-GATED: runs only when the operator
14+
* supplies a known-valid and known-invalid identifier (that config is the opt-in to the
15+
* two probes). Sends the same auth operation twice (dummy password → failed logins,
16+
* non-destructive) and reports a response differential that lets an attacker tell which
17+
* identifiers exist.
18+
*/
19+
class UserEnumerationCheck : GraphQLCheck {
20+
override val id = "user-enumeration"
21+
override val owaspId = "API2:2023"
22+
23+
override fun run(ctx: CheckContext): List<Finding> {
24+
val cfg = ctx.config
25+
if (!cfg.hasUserEnumConfig) return emptyList()
26+
val schema = ctx.schema ?: return emptyList()
27+
28+
val field = (schema.queries() + schema.mutations()).firstOrNull { f ->
29+
Heuristics.isAuthField(f.name) && f.args.any { Heuristics.isIdentifierArg(it.name) }
30+
} ?: return emptyList()
31+
val idArg = field.args.first { Heuristics.isIdentifierArg(it.name) }
32+
33+
val validId = cfg.userEnumValid!!
34+
val invalidId = cfg.userEnumInvalid!!
35+
val rrValid = GraphQLHttp.postJson(ctx.api, ctx.request, GraphQLHttp.queryEnvelope(QueryBuilder.injectedQuery(schema, field, idArg.name, validId)))
36+
val rrInvalid = GraphQLHttp.postJson(ctx.api, ctx.request, GraphQLHttp.queryEnvelope(QueryBuilder.injectedQuery(schema, field, idArg.name, invalidId)))
37+
val bValid = rrValid.response()?.bodyToString().orEmpty()
38+
val bInvalid = rrInvalid.response()?.bodyToString().orEmpty()
39+
if (!reveals(bValid, bInvalid, validId, invalidId)) return emptyList()
40+
41+
return listOf(
42+
Finding(
43+
name = "GraphQL user enumeration via ${field.name} (distinct responses for valid vs invalid identifier)",
44+
detail = """
45+
The auth operation `${field.name}` responded differently for a known-valid
46+
identifier than for a known-invalid one (same dummy password), so an attacker can
47+
determine which accounts exist — enabling targeted credential stuffing, password
48+
spraying and phishing.
49+
50+
Probes used failed logins only; no account was accessed.
51+
52+
CVSS v3.1: AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N (5.3, Medium) — unauthenticated
53+
disclosure of account existence.
54+
""".trimIndent(),
55+
severity = Severity.MEDIUM,
56+
confidence = Confidence.FIRM,
57+
remediation = """
58+
Return a single generic message for all authentication failures (never
59+
distinguish "no such user" from "wrong password"), keep response timing uniform,
60+
and apply the same rate limiting to valid and invalid identifiers.
61+
""".trimIndent(),
62+
evidence = listOf(rrValid, rrInvalid),
63+
),
64+
)
65+
}
66+
67+
companion object {
68+
/** True when the two responses differ in error templates (identifiers stripped) or data presence. */
69+
fun reveals(validBody: String, invalidBody: String, validId: String, invalidId: String): Boolean {
70+
val tValid = templates(GraphQLHttp.errorMessages(validBody), validId, invalidId)
71+
val tInvalid = templates(GraphQLHttp.errorMessages(invalidBody), validId, invalidId)
72+
if (tValid != tInvalid) return true
73+
return GraphQLHttp.hasData(validBody) != GraphQLHttp.hasData(invalidBody)
74+
}
75+
76+
/** Normalize messages: drop the identifiers, collapse digits, lowercase — compare the templates. */
77+
private fun templates(messages: List<String>, vararg ids: String): Set<String> =
78+
messages.map { msg ->
79+
var m = msg.lowercase()
80+
ids.forEach { m = m.replace(it.lowercase(), "") }
81+
m.replace(Regex("\\d+"), "#").replace(Regex("\\s+"), " ").trim()
82+
}.toSet()
83+
}
84+
}

‎src/main/kotlin/com/redcell/gqlanalyzer/model/CheckContext.kt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ data class CheckConfig(
1919
val knownObjectId: String? = null,
2020
/** Max nesting depth for the single depth-proof query. Never escalated. */
2121
val depthProof: Int = 10,
22+
/** A known-valid identifier (username/email) for the user-enumeration probe. */
23+
val userEnumValid: String? = null,
24+
/** A known-invalid identifier for the user-enumeration probe. */
25+
val userEnumInvalid: String? = null,
2226
) {
2327
val hasTwoIdentities: Boolean get() = authHeadersA.isNotEmpty() && authHeadersB.isNotEmpty()
28+
29+
val hasUserEnumConfig: Boolean
30+
get() = !userEnumValid.isNullOrBlank() && !userEnumInvalid.isNullOrBlank()
2431
}
2532

2633
/**

‎src/main/kotlin/com/redcell/gqlanalyzer/ui/TargetPanel.kt‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class TargetPanel(
4848
private val identityA = JTextArea(3, 24)
4949
private val identityB = JTextArea(3, 24)
5050
private val knownIdField = JTextField(16)
51+
private val userEnumValidField = JTextField(16)
52+
private val userEnumInvalidField = JTextField(16)
5153

5254
private val operationsModel = OperationsTableModel()
5355
private val operationsTable = JTable(operationsModel)
@@ -96,10 +98,16 @@ class TargetPanel(
9698
config.add(labeled("Identity B (attacker)", JScrollPane(identityB)))
9799
config.add(labeled("Known object id (A-owned)", knownIdField))
98100

101+
val enumRow = JPanel(GridLayout(1, 2, 8, 8))
102+
enumRow.border = BorderFactory.createTitledBorder("User enumeration (optional) — enables the API2 login-differential probe")
103+
enumRow.add(labeled("Valid identifier (existing user)", userEnumValidField))
104+
enumRow.add(labeled("Invalid identifier (no such user)", userEnumInvalidField))
105+
99106
val wrapper = JPanel(BorderLayout(8, 8))
100107
wrapper.add(config, BorderLayout.NORTH)
108+
wrapper.add(enumRow, BorderLayout.CENTER)
101109
wrapper.add(
102-
JLabel("Identities drive BOLA/BFLA (skipped unless set). Credentials are never stored outside this tab."),
110+
JLabel("Identities drive BOLA/BFLA; user-enum fields drive API2. All optional, skipped unless set; never stored outside this tab."),
103111
BorderLayout.SOUTH,
104112
)
105113
return wrapper
@@ -147,6 +155,8 @@ class TargetPanel(
147155
authHeadersA = AnalyzerTab.parseHeaders(identityA.text),
148156
authHeadersB = AnalyzerTab.parseHeaders(identityB.text),
149157
knownObjectId = knownIdField.text.trim().ifEmpty { null },
158+
userEnumValid = userEnumValidField.text.trim().ifEmpty { null },
159+
userEnumInvalid = userEnumInvalidField.text.trim().ifEmpty { null },
150160
)
151161

152162
/** Introspect, enumerate operations, and run endpoint-level checks. */

0 commit comments

Comments
 (0)