Skip to content

Fix:Uncontrolled data used in path expression - #162

Draft
ea-rus wants to merge 16 commits into
stagingfrom
fix-alert-27
Draft

Fix:Uncontrolled data used in path expression#162
ea-rus wants to merge 16 commits into
stagingfrom
fix-alert-27

Conversation

@ea-rus

@ea-rus ea-rus commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Fix CodeQL alerts by adding extra check:

  • create function
  • is_relative_to

Fix multiple CodeQL path-injection (py/path-injection) findings by replacing pathlib.relative_to() containment checks with the os.path.normpath + str.startswith idiom that static analysis recognizes as a sanitizer.
Extracted the shared check into cowork/common/path_utils.is_relative_to()

Fixes https://linear.app/mindsdb/issue/ENG-686/fix-uncontrolled-data-used-in-path-expression-alerts

Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
def _project_path(self, name: str) -> Path:
return self._root_dir() / name
root = self._root_dir().resolve()
candidate = (self._root_dir() / name).resolve()
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
@ea-rus
ea-rus marked this pull request as draft July 7, 2026 08:07
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
target = (base / file_path).resolve()
target.relative_to(base.resolve())
target = (base_path / file_path).resolve()
target.relative_to(base_path.resolve())
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
Comment thread cowork/api/v1/endpoints/artifacts.py Fixed
target = (base / file_path).resolve()
target.relative_to(base.resolve())
# codeql[py/path-injection]
target = (base_path / file_path).resolve()
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