Skip to content

Fix lab verifier path traversal in lab runtime#20

Closed
beyildirim wants to merge 1 commit intomainfrom
codex/fix-codeql-path-injection
Closed

Fix lab verifier path traversal in lab runtime#20
beyildirim wants to merge 1 commit intomainfrom
codex/fix-codeql-path-injection

Conversation

@beyildirim
Copy link
Copy Markdown
Owner

This fixes the open CodeQL path-injection finding in weaklink_platform/lab_runtime.py by resolving verifier paths under an allowed root before touching verify.py.

Changes:

  • Added descendant path confinement before resolving the lab verifier path.
  • Fail closed with an invalid lab path error when a lab id escapes the configured labs root.
  • Added a regression test for traversal-style lab ids.

Validation:

  • python3 -m pytest tests/platform/test_lab_runtime.py
  • python3 -m ruff check weaklink_platform/lab_runtime.py tests/platform/test_lab_runtime.py



def _resolve_descendant(root: Path, child: str | Path) -> Path:
resolved_root = root.resolve(strict=False)

def _resolve_descendant(root: Path, child: str | Path) -> Path:
resolved_root = root.resolve(strict=False)
resolved_child = (resolved_root / child).resolve(strict=False)
@beyildirim
Copy link
Copy Markdown
Owner Author

Closing this PR to recreate it from the same commit on a neutral branch name.

@beyildirim beyildirim closed this Apr 14, 2026
@beyildirim beyildirim deleted the codex/fix-codeql-path-injection branch April 14, 2026 21:19
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