[AAASM-3169] 🔒 (python-sdk): Fix S8707 path-traversal in adapter_validator CLI#141
Conversation
A CLI-supplied path_or_module flowed into open() unvalidated, letting a crafted argument (.., absolute paths, symlinks) read arbitrary pyproject.toml files outside the adapter directory (pythonsecurity:S8707). resolve() the constructed manifest path and reject any pyproject.toml whose canonical parent is not the resolved adapter directory, breaking the taint flow and bounding traversal while preserving legitimate validation. Refs: AAASM-3169 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add tests for the S8707 fix: a '..' path that canonicalizes back to a real adapter dir still validates, and a pyproject.toml symlink escaping the adapter directory is refused rather than read. Refs: AAASM-3169 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
🤖 Claude Code — PR ReviewDisclosure: Authored by a sub-agent I orchestrated under the AAASM-3169 fan-out. Reviewing critically — this is a real security fix, so it got the closest look. 1. CI verdict15/15 green (6 skipped are env-gated e2e/optional-framework). No failures. 2. Scope review vs AAASM-3169 — 1/1 resolved
3. Quality observations (read the diff + reasoning)
4. Verdict🟢 APPROVED. The one genuinely-serious finding of this batch — a path-traversal in a CLI that takes LLM/operator-supplied paths — fixed correctly with a real guard + regression tests. SonarCloud auto-clears S8707 on next scan. Generated by Claude Code (Opus 4.8, 1M ctx) · scope: CI triage + AAASM-3169 AC verification + taint-fix correctness review |



Description
Fixes the one open VULNERABILITY on
python-sdkmaster (SonarCloudpythonsecurity:S8707, MAJOR,agent_assembly/cli/adapter_validator.py:189).aasm adapter validate <path_or_module>flowed a CLI-supplied path straight intoPath(...)→open(pyproject_path)with no validation, so a crafted argument (../../..., absolute paths, or a symlinkedpyproject.toml) could read arbitrarypyproject.tomlfiles outside the intended adapter directory.The fix
resolve()s the constructed manifest path (collapsing../symlinks — this breaks Sonar's argv→open() taint flow) and adds a real containment guard: the resolvedpyproject.toml's canonical parent must equal the resolved adapter directory, otherwise the manifest is refused rather than read. Legitimate validation of a real adapter dir/module is unchanged.Per-finding resolution
pythonsecurity:S8707path-traversalagent_assembly/cli/adapter_validator.py:189.resolve()canonicalizes the manifest path before access + containment guard rejecting anypyproject.tomlresolving outside the adapter directoryType of Change
Breaking Changes
A legitimate adapter directory's own
pyproject.tomlis read exactly as before; only manifests reached by escaping the adapter directory (e.g. an out-of-tree symlink) are now refused.Related Issues
Testing
Added to
TestCheckEntryPointMetadata:test_traversal_path_resolved_to_valid_dir— a..path that canonicalizes back to a real adapter dir still validates (legitimate behaviour preserved).test_symlinked_pyproject_outside_dir_rejected— apyproject.tomlsymlink escaping the adapter dir is refused, not read (skips on platforms without symlink support).Test Plan / validation run:
.venv/bin/python -m pytest test/→ 515 passed, 13 skipped (skips are native_core/optional-framework, pre-existing)..venv/bin/pre-commit run --files <changed>→ isort, autoflake, black, mypy all Passed..venv/bin/mypy agent_assembly→ only pre-existingagent_assembly._coreimport-not-found errors (native PyO3 ext not built locally); unrelated to this change..venv/bin/ruff check .→ pre-existing baseline errors only (ruff is not wired into CI or pre-commit here; the changed files introduce zero new ruff findings, and the loneB009in this module predates this PR).Operator safe-ack recommendation
None — this is a real guard that breaks the taint flow; no SonarCloud "Safe" acknowledgement is needed. SonarCloud should clear S8707 on the next scan.
Checklist
🤖 Generated with Claude Code