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

ReadFileBytes panics when a provided path is empty #275

Open
ahpaleus opened this issue Sep 19, 2023 · 0 comments
Open

ReadFileBytes panics when a provided path is empty #275

ahpaleus opened this issue Sep 19, 2023 · 0 comments
Assignees
Labels

Comments

@ahpaleus
Copy link

ahpaleus commented Sep 19, 2023

When the ReadFileBytes function is called with an empty string as the file path (ReadFileBytes("")), it leads to panic because the subsequent call to the expandHomePath function checks if the first character is a tilde. While this issue might not immediately expose a vulnerability, it could cause disruptions in certain scenarios.

To mitigate this, it is recommended to:

  • Proactively check for empty paths. To prevent the panic scenario, add an early check at the beginning of the expandHomePath function to ensure the file path is not empty.
  • Review the codebase for duplicated code. We detected the presence of duplicate, error-prone ReadFileBytes functions within the go-authcrunch package.
  • Implement unit testing. To ensure the correct functionality of these functions, comprehensive unit tests should be created. These tests should cover various scenarios, including valid and invalid file paths.
  • Leverage fuzz testing. In addition to unit tests, use Golang’s native fuzz tests to increase the robustness of the go-authcrunch package. Native fuzz tests can be conveniently appended to the regular *_test.go test suite and do not need any overhead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants