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

Abzu-160537-fix snyk issue related to Path Traversal #323

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JiviteshT
Copy link
Contributor

No description provided.

@JiviteshT JiviteshT requested review from rockydevnet and a team as code owners June 12, 2024 15:01
@JiviteshT JiviteshT force-pushed the Feature/Abzu-160537-fix-pthtraversal-issue branch from 2a8c62e to 87210c4 Compare June 14, 2024 08:32
@@ -96,7 +97,7 @@ public ActionResult DownloadFile(string batchId, string fileName)
}
if (!string.IsNullOrEmpty(fileName))
{
bytes = fileShareService.GetFileData(configuration["HOME"], batchId, fileName);
bytes = fileShareService.GetFileData(configuration["HOME"], Sanitise(batchId), fileName);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're (rightly) sanitising the BatchId, should we also consider the same for the filename? The filename is not allowed to include any path characters. It would be harder to provide an allowed list of characters, but we could exclude \, /, and :

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also just realised that this is a mock, so possibly not worth doing!

HttpContext.Response.Headers.Add("x-redirect-status", "true");
}

return File(bytes, "application/octet-stream", fileName);
}

public static string Sanitise(string text)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very generic method name for a rather specific sanitisation. Should it be called something like SanitiseBatchId? For example, it wouldn't be correct to use the current method to sanitise any other input.

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

Successfully merging this pull request may close these issues.

2 participants