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
}
@@ -297,8 +299,10 @@ func (r *RFC7662Provider) IntrospectToken(ctx context.Context, token string) (jw
297
299
}
298
300
defer resp .Body .Close ()
299
301
300
- // Read response body
301
- body , err := io .ReadAll (resp .Body )
302
+ // Read response body with a reasonable limit to prevent DoS attacks
303
+ const maxResponseSize = 64 * 1024 // 64KB should be more than enough for introspection response
304
+ limitedReader := io .LimitReader (resp .Body , maxResponseSize )
305
+ body , err := io .ReadAll (limitedReader )
302
306
if err != nil {
303
307
return nil , fmt .Errorf ("failed to read introspection response: %w" , err )
304
308
}
You can’t perform that action at this time.
0 commit comments