Skip to content

Commit 138b0ee

Browse files
committed
internal/oauthex: limit PRM body size
1 parent 29c1650 commit 138b0ee

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/oauthex/resource_meta.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"encoding/json"
1313
"errors"
1414
"fmt"
15+
"io"
1516
"net/http"
1617
"net/url"
1718
"path"
@@ -187,7 +188,8 @@ func getPRM(ctx context.Context, url string, c *http.Client, wantResource string
187188
}
188189

189190
var prm ProtectedResourceMetadata
190-
dec := json.NewDecoder(res.Body)
191+
// Use a LimitReader to avoid maliciously large payloads.
192+
dec := json.NewDecoder(io.LimitReader(res.Body, 1<<20))
191193
if err := dec.Decode(&prm); err != nil {
192194
return nil, err
193195
}

0 commit comments

Comments
 (0)