T07 · Tool Hijacking and Spoofing
- Location
src/config_editor.py:371- Finding
Untrusted Configuration Directory Can Override the Manga Layout Launcher
- Content
View full analysis
Vulnerability Details
File Location:
src/config_editor.py:371-385, 398-424
Vulnerability Type: Untrusted local tool resolution and execution
Risk Level: HighVulnerable Code
python def find_run_script(config_path): script_dir = os.path.dirname(os.path.abspath(__file__)) config_dir = os.path.dirname(os.path.abspath(config_path)) if os.name == "posix": candidates = [ os.path.join(config_dir, "run_manga_layout.sh"), os.path.join(script_dir, "run_manga_layout.sh"), ] else: candidates = [ os.path.join(config_dir, "run_manga_layout.ps1"), os.path.join(script_dir, "run_manga_layout.ps1"), ] for path in candidates: if os.path.exists(path): return path return None def get_run_command(script_path): if script_path.endswith(".sh"): return ["/bin/bash", script_path] return ["powershell", script_path] def cli_run(args): config_path = args.config or find_default_config() if not config_path or not os.path.exists(config_path): print("Error: configuration file not found", file=sys.stderr, flush=True) sys.exit(1) script_path = find_run_script(config_path) if not script_path: script_name = "run_manga_layout.sh" if os.name == "posix" else "run_manga_layout.ps1" print(f"Error: script file not found: {script_name}", file=sys.stderr, flush=True) sys.exit(1) script_dir = os.path.dirname(script_path) target_config = os.path.join(script_dir, "manga_layout_config.json") try: abs_source = os.path.abspath(config_path) abs_target = os.path.abspath(target_config) if abs_source != abs_target: shutil.copyfile(config_path, target_config) except Exception as e: print(f"Error: failed to copy configuration into execution directo ...[truncated 2313 chars]- Remediation
View remediation
Remediation Suggestions
- Resolve launchers exclusively from the trusted directory containing
config_editor.py. - Canonicalize the selected path with
os.path.realpath()and verify that it remains under the trusted project directory. - Check that the selected path is a regular file rather than only testing
os.path.exists(). - Do not automatically execute a launcher located beside an externally supplied configuration.
- If external launchers are an intentional feature, require a separate explicit option, display the exact path, obtain user confirmation, and verify an approved digital signature or cryptographic digest.
- On Windows, invoke PowerShell with an explicit file argument, such as
powershell -File <trusted-path>, and apply an appropriate execution policy. - Add tests proving that a configuration directory containing a same-named launcher cannot override the bundled launcher.
- Resolve launchers exclusively from the trusted directory containing
