You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the version or commit of the ORAS .NET library?
No response
What would you like to be added?
It seems the ORAS dotnet ManifestStore operations utilize the HttpResponse.Content.ReadAsStreamAsync for loading response body content into a stream. This can be potentially unsafe as the underlying MemoryStream buffer size is by default set to be the Int.MaxSize which comes to be ~2gb. This can lead to potential memory exhaustion if the upstream server is malicious and reports an incorrect Content-Length in the headers. There should be a check to enforce a max size (maybe 4mb) and have this be overridable.
With the new auth client introduced in #200, Repository now replies on an IClient interface and accepts customized HTTP clients.
Users can configure the MaxResponseContentBufferSize property on their HttpClient and pass the client to ORAS.
Additionally, we will have another feature #167 to limit the max size of response body buffered for internal processing.
What is the version or commit of the ORAS .NET library?
No response
What would you like to be added?
It seems the ORAS dotnet
ManifestStore
operations utilize theHttpResponse.Content.ReadAsStreamAsync
for loading response body content into a stream. This can be potentially unsafe as the underlyingMemoryStream
buffer size is by default set to be theInt.MaxSize
which comes to be ~2gb. This can lead to potential memory exhaustion if the upstream server is malicious and reports an incorrectContent-Length
in the headers. There should be a check to enforce a max size (maybe 4mb) and have this be overridable.oras-dotnet/src/OrasProject.Oras/Registry/Remote/ManifestStore.cs
Line 69 in b036aa4
Taking a look at the source code for
ReadAsStreamAsync
,https://github.com/dotnet/runtime/blob/5535e31a712343a63f5d7d796cd874e563e5ac14/src/libraries/System.Net.Http/src/System/Net/Http/HttpContent.cs#L286
you can see that if the content has not been loaded before into a temporary buffer, a new buffer is created with the size
MaxSizeBytes
https://github.com/dotnet/runtime/blob/5535e31a712343a63f5d7d796cd874e563e5ac14/src/libraries/System.Net.Http/src/System/Net/Http/HttpContent.cs#L550
Why is this needed for the ORAS .NET library?
Protect clients from large responses.
Are you willing to submit PRs to contribute to this feature?
The text was updated successfully, but these errors were encountered: