Skip to content

Conversation

@praveenkk123
Copy link
Contributor

Potential fix for https://github.com/intel/AI-PC-Samples/security/code-scanning/56

To fix the issue, we need to ensure that any path constructed for accessing local files under the data directory is validated such that it remains within the data directory and cannot escape via .., absolute paths, or symlinks. The best approach is to join the base directory with the user-supplied path, normalize the result (with os.path.normpath), and then check that the resulting path starts with the intended base directory (data_dir). If the check fails, raise an error and do not proceed to read the file.

Changes are needed only in the load_document function, specifically in the "else" block when loading from the local file system (lines 88-103). No other logic or functionality needs to change. No external packages are required for this mitigation.


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

…in path expression

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.

2 participants