mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-19 06:27:38 +00:00
fix(auth): verify JWT signature to prevent cache-key forgery (GHSA-9gqw-h2rw-44wv)
The proxy derived per-user GraphQL cache keys from JWT claims without verifying the token signature (CWE-345). A remote attacker could forge a token that carried a victim's claim value and read the victim's cached response. This change adds opt-in signature verification behind JWT_VERIFY_SIGNATURE. The flag defaults to false, so an upgrade without a config change keeps the previous delegate-to-upstream behavior byte for byte. When verification is on, the operator must set exactly one key source: JWT_SECRET, JWT_PUBLIC_KEY, or JWT_JWKS_URL. The verifier pins the accepted algorithms to the key family through WithValidMethods and a type-switched keyfunc, and it refuses alg=none. This closes the algorithm-confusion class of attack. A present but invalid token now returns 401. A missing Authorization header stays anonymous. Startup fails loudly when verification is on and the key source is absent or unreadable, so the proxy can never boot half-configured.
This commit is contained in:
+20
-15
@@ -42,21 +42,26 @@ type config struct {
|
||||
PerUserCacheDisabled bool // Disable per-user cache isolation (SECURITY RISK - not recommended)
|
||||
}
|
||||
Client struct {
|
||||
GQLClient *graphql.BaseClient
|
||||
FastProxyClient *fasthttp.Client
|
||||
JWTUserClaimPath string
|
||||
JWTRoleClaimPath string
|
||||
RoleFromHeader string
|
||||
proxy string
|
||||
ClientTimeout int
|
||||
MaxConnsPerHost int
|
||||
ReadTimeout int
|
||||
WriteTimeout int
|
||||
MaxIdleConnDuration int
|
||||
RetryBaseDelayMs int // initial backoff delay in milliseconds (default 500)
|
||||
RetryMaxDelayMs int // maximum backoff delay in milliseconds (default 10000)
|
||||
RoleRateLimit bool
|
||||
DisableTLSVerify bool
|
||||
GQLClient *graphql.BaseClient
|
||||
FastProxyClient *fasthttp.Client
|
||||
JWTUserClaimPath string
|
||||
JWTRoleClaimPath string
|
||||
// JWTVerifier verifies JWT signatures before extractClaimsFromJWTHeader
|
||||
// trusts a claim from the token (GHSA-9gqw-h2rw-44wv). nil (the default)
|
||||
// means JWT_VERIFY_SIGNATURE is off and claims are decoded unverified,
|
||||
// exactly like before this field existed.
|
||||
JWTVerifier *JWTVerifier
|
||||
RoleFromHeader string
|
||||
proxy string
|
||||
ClientTimeout int
|
||||
MaxConnsPerHost int
|
||||
ReadTimeout int
|
||||
WriteTimeout int
|
||||
MaxIdleConnDuration int
|
||||
RetryBaseDelayMs int // initial backoff delay in milliseconds (default 500)
|
||||
RetryMaxDelayMs int // maximum backoff delay in milliseconds (default 10000)
|
||||
RoleRateLimit bool
|
||||
DisableTLSVerify bool
|
||||
}
|
||||
Server struct {
|
||||
HostGraphQL string
|
||||
|
||||
Reference in New Issue
Block a user