Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing null check for boundary #150

Open
JornWildt opened this issue Aug 2, 2018 · 1 comment
Open

Missing null check for boundary #150

JornWildt opened this issue Aug 2, 2018 · 1 comment

Comments

@JornWildt
Copy link

JornWildt commented Aug 2, 2018

In OpenRasta/IO/BoundaryStreamReader.cs we have:

public BoundaryStreamReader(string boundary, Stream baseStream, Encoding streamEncoding, int bufferLength)
{
  if (baseStream == null)
    throw new ArgumentNullException("baseStream");
  if (!baseStream.CanSeek || !baseStream.CanRead)
    throw new ArgumentException("baseStream must be a seekable readable stream.");
  if (bufferLength < boundary.Length + 6)
    throw new ArgumentOutOfRangeException(nameof(bufferLength),
      "The buffer needs to be big enough to contain the boundary and control characters (6 bytes)");

Unfortunately, if you screw up your request and forget the boundary element in the content-type header, you can have boundary = null in which case if (bufferLength < boundary.Length + 6) fails with a null reference, making it difficult to know what happend.

In my case someone decided to send this equest:

POST ...
Content-Type: multipart/form-data
... other headers ...
boundary: 125a17bf-935d-4686-b0c9-95a9543bf255
Content-Length: ...
@serialseb
Copy link
Member

Interesting. Boundary is required so in case it's invalid we should send back a 400 indeed, especially as it's a required element. For reference, rfc is at https://tools.ietf.org/html/rfc7578

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants