Skip to content

Commit

Permalink
first attempt to solve path traversal vulnerability with unsanitized …
Browse files Browse the repository at this point in the history
…input
  • Loading branch information
LucaPaterlini committed Jul 24, 2024
1 parent 79050a9 commit 48e11cd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Alba/HttpRequestBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ public void XmlInputIs(object target)

private void writeTextToBody(string json, HttpContext context)
{
var stream = context.Request.Body;

var writer = new StreamWriter(stream);
var stream = new MemoryStream();
using var writer = new StreamWriter(stream);
writer.Write(json);
writer.Flush();

stream.Position = 0;

context.Request.Body = stream;
context.Request.ContentLength = stream.Length;
}


public void WriteFormData(Dictionary<string, string> input)
{
_parent.ConfigureHttpContext(context =>
Expand Down

0 comments on commit 48e11cd

Please sign in to comment.