File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -123,8 +123,10 @@ func (g *GoogleProvider) IntrospectToken(ctx context.Context, token string) (jwt
123
123
}
124
124
defer resp .Body .Close ()
125
125
126
- // Read the response
127
- body , err := io .ReadAll (resp .Body )
126
+ // Read the response with a reasonable limit to prevent DoS attacks
127
+ const maxResponseSize = 64 * 1024 // 64KB should be more than enough for tokeninfo response
128
+ limitedReader := io .LimitReader (resp .Body , maxResponseSize )
129
+ body , err := io .ReadAll (limitedReader )
128
130
if err != nil {
129
131
return nil , fmt .Errorf ("failed to read Google tokeninfo response: %w" , err )
130
132
}
@@ -298,8 +300,10 @@ func (r *RFC7662Provider) IntrospectToken(ctx context.Context, token string) (jw
298
300
}
299
301
defer resp .Body .Close ()
300
302
301
- // Read response body
302
- body , err := io .ReadAll (resp .Body )
303
+ // Read response body with a reasonable limit to prevent DoS attacks
304
+ const maxResponseSize = 64 * 1024 // 64KB should be more than enough for introspection response
305
+ limitedReader := io .LimitReader (resp .Body , maxResponseSize )
306
+ body , err := io .ReadAll (limitedReader )
303
307
if err != nil {
304
308
return nil , fmt .Errorf ("failed to read introspection response: %w" , err )
305
309
}
You can’t perform that action at this time.
0 commit comments