Skip to content

[Security Patch Suggestion] Patch for medium severity vulnerabilities#12

Open
nuang-ee wants to merge 2 commits into
ImLunaHey:mainfrom
nuang-ee:patch-1
Open

[Security Patch Suggestion] Patch for medium severity vulnerabilities#12
nuang-ee wants to merge 2 commits into
ImLunaHey:mainfrom
nuang-ee:patch-1

Conversation

@nuang-ee
Copy link
Copy Markdown

Disclaimer

I understand that this repository is not under active maintenance, however I'm leaving this patch for anyone who have decided to use this project.

If this PR is yet not merged into the project, it is recommended to apply this patch by yourself, before using this project!

Description

This PR fixes two medium severity security bugs:

The path confusion problem

Current version of this project fails to properly strip the pathname via config. For an instance, when server is configured as: Bun.serve({ fetch: serveStatic(".", { stripFromPathname: "/public"})});, /public/images/image.png, /images/public/image.png, and even /imag/publices/image.png is evaluated into same local filesystem path: {rootDirectory}/images/image.png.

This may lead to unintended access to protected files.

The unprotected "dot-directory" access

Current implementation only checks if the last segment of file URL, separated by /, is starting with .. However, common practice is to prevent access to directories that have name starting with ., and all of its children. For instance, directories like .vscode, .git should be protected.

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.

1 participant