harden: the cli tools `utils/validate_skill in validate_skill.py - #327
harden: the cli tools `utils/validate_skill in validate_skill.py#327anupamme wants to merge 1 commit into
Conversation
Automated security fix generated by OrbisAI Security Signed-off-by: anupamme <mediratta@gmail.com>
MergerNeeds Review ESCALATE: the new path-containment check is only in Commit |
| # Guard against path traversal: resolved path must stay within skills/ | ||
| base_dir = (Path(__file__).parent.parent / "skills").resolve() | ||
| resolved = Path(skill_path).resolve() | ||
| if not resolved.is_relative_to(base_dir): | ||
| print(f"Error: skill path must be within the 'skills' directory ({base_dir})") |
There was a problem hiding this comment.
CLI-only skill-root containment
The skills/ containment guard only lives in main(), so utils/package_skill.py can call validate_skill() directly with an out-of-tree path and make us read and validate an external skill.json. Should we move that guard into validate_skill() or a shared helper and reuse it from both main() and package_skill()?
Want Baz to fix this for you? Activate Fixer
Other fix methods
Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
utils/validate_skill.py around lines 135-139 within main(), remove or stop treating the
skills containment guard as only a direct-execution concern. Instead, move the
base_dir/resolved path traversal check into the reusable validate_skill() logic (or a
shared helper used by both main() and validate_skill()), and ensure validate_skill()
rejects any skill_path that resolves outside the repository’s skills directory before
it constructs/reads skill_json_path. Then update main() (and confirm
utils/package_skill.py continues calling validate_skill()) so all callers get the same
containment protection.
User description
Summary
Harden input handling in
utils/validate_skill.py(flagged by multi_agent_ai).Vulnerability
V-001utils/validate_skill.py:133Description: The CLI tools
utils/validate_skill.pyandutils/package_skill.pyaccept askill_pathargument directly fromsys.argv[1]without validating that the resolved path stays within an expected base directory. WhilePath(skill_path).resolve()normalizes the path, there is no check that the resolved path is within an allowed directory. An attacker who can invoke these scripts can supply../../etc/or any absolute path to read arbitrary files.Threat Model Context
This is a web application - XSS and injection vulnerabilities can affect end users.
Changes
utils/validate_skill.pyBehavior Preservation
The change is scoped to 1 file on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.
Security Invariant
Regression test
This test guards against regressions — it's useful independent of the code change above.
This patch removes an exploit primitive — a code pattern that, while not independently exploitable today, could be chained with other weaknesses by automated exploit-development tooling. Proactive removal of such primitives raises the bar against increasingly capable automated attack tools.
Automated security fix by OrbisAI Security
Generated description
Below is a concise technical summary of the changes proposed in this PR:
Harden
utils.validate_skill'smain()to resolve the CLIskill_pathagainst the repositoryskillsdirectory and reject paths that escape it. Preserve valid skill validation while blocking traversal inputs fromsys.argv[1].Latest Contributors(0)