T09 · Insecure Skill Coding Practices
- Location
ab_predictor.py:36- Finding
Automatic Execution of an Unverified Sibling Python Module
- Content
View full analysis
Vulnerability Details
File Location:
ab_predictor.py, lines 36–49
Vulnerability Type: Unsafe dynamic module loading from an implicitly trusted relative path
Risk Level: MediumVulnerable Code:
python def _load_crs(): """Load content_resonance_scorer from sibling project dir.""" here = _pl.Path(__file__).parent scorer_path = here.parent / "content-resonance-scorer" / "content_resonance_scorer.py" if not scorer_path.exists(): return None spec = _ilu.spec_from_file_location("content_resonance_scorer", scorer_path) mod = _ilu.module_from_spec(spec) spec.loader.exec_module(mod) return mod _CRS = _load_crs()Technical Analysis
The Skill constructs a path outside its own project directory and executes the Python module found there through
exec_module(). It verifies only that the path exists; it does not validate the module's origin, integrity, ownership, permissions, signature, or expected hash._load_crs()is called at module initialization, before command-line arguments are parsed. Consequently, the sibling module's top-level code is executed for every invocation, including operations that should be non-executing or low risk, such as--helpand--version.This creates a local code-execution trust boundary: any user, package, or compromised process capable of creating or modifying
../content-resonance-scorer/content_resonance_scorer.pycan cause arbitrary Python code to run under the identity of the user or Agent invoking this Skill.Attack Path
- An attacker gains the ability to create or modify the sibling path
../content-resonance-scorer/content_resonance_scorer.py. - The attacker places arbitrary top-level Python code in that file.
- A user or Agent invokes
ab_predictor.pywith any arguments, including--helpor--version. - Python imports
ab_predictor.py, evaluates_CRS = _load_crs(), and locates the at ...[truncated 1234 chars]
- An attacker gains the ability to create or modify the sibling path
- Remediation
View remediation
Remediation Suggestions
- Remove automatic module execution from the relative sibling directory.
- Package the premium backend as an explicit, version-pinned dependency obtained from a trusted source.
- Require explicit user opt-in before enabling the optional backend, such as a dedicated
--backendargument or trusted configuration setting. - Parse command-line arguments before loading optional executable code. Do not load the backend for
--help,--version, or internal-only scoring. - If file-based plugin loading is necessary:
- Restrict plugins to an administrator-controlled directory.
- Resolve the path canonically and ensure it remains within the approved directory.
- Reject files with unsafe ownership or writable permissions.
- Verify a pinned cryptographic hash or trusted digital signature before import.
- Fail closed when verification cannot be completed.
- Document the backend's trust boundary and installation procedure rather than silently treating any file at the sibling path as trusted.
- Add tests confirming that unverified sibling files are never imported and that informational commands do not execute optional backend code.
