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

Fix code scanning alert no. 9: Uncontrolled data used in path expression #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jsommer
Copy link

@jsommer jsommer commented Sep 26, 2024

Fixes https://github.com/GitHub-Partner-Demo-Library/MicrosoftCopilotHackathon/security/code-scanning/9

To fix the problem, we need to validate the user-provided path to ensure it does not contain any directory traversal sequences or path separators that could lead to accessing unauthorized files. We will:

  1. Normalize the path to remove any redundant elements.
  2. Ensure the path is within a specific directory (e.g., a base directory) to prevent access to unauthorized locations.
  3. Reject the input if it contains any invalid sequences.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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