T09 · Insecure Skill Coding Practices
- Location
remove_bg.py:34- Finding
Windows Shell Command Injection Through Attacker-Controlled Output Path
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This image background-removal skill mostly does what it says, but it also automatically opens the output file and uses a risky Windows shell call that is not clearly disclosed.
Review before installing. The skill appears intended for local image conversion and does not show network access or persistence, but the helper should be changed so opening the output image is an explicit option and the Windows shell=True call is removed. Use only trusted input and output paths until then.
remove_bg.py:34Windows Shell Command Injection Through Attacker-Controlled Output Path
The natural-language content describing the skill, usage, examples, and implementation is presented only in Chinese. Under the stated policy, forcing a specific language without user opt-in or a documented regional justification is a language/locale policy violation.
The module documentation describes only background removal and saving a PNG, but the code also launches the generated file in the system viewer. This hidden side effect undermines user trust and makes the script more dangerous because users are not informed that it will execute external viewer commands.
Executing system viewer commands is not required to remove an image background and save output. Adding external program launch capability increases attack surface and can be abused in environments where scripts are expected to perform only local file transformation.
The script forces automatic opening of the generated image without asking the user. In a skill or automation context, unexpected application launches are particularly risky because they can trigger external handlers, disrupt workflows, and violate least-surprise expectations.
On Windows, the script invokes a shell-backed command to open the output file automatically. Although the argument is derived from the output path, using shell=True introduces unnecessary command-execution surface and the auto-launch behavior is unrelated to the documented core function of background removal.
try:
import subprocess, sys
if sys.platform.startswith('win'):
subprocess.run(['start', str(out_path)], shell=True, check=False)
elif sys.platform.startswith('darwin'):
subprocess.run(['open', str(out_path)], check=False)
else:
The macOS open command launches an external application based on the generated file without user consent. This is less severe than shell-based execution, but it still causes unexpected execution of external programs and expands the script's behavior beyond simple image processing.
if sys.platform.startswith('win'):
subprocess.run(['start', str(out_path)], shell=True, check=False)
elif sys.platform.startswith('darwin'):
subprocess.run(['open', str(out_path)], check=False)
else:
subprocess.run(['xdg-open', str(out_path)], check=False)
except Exception as e:
The xdg-open call triggers the desktop's default handler for the saved file, causing external program execution without opt-in. While commonly used for convenience, it is unnecessary for the stated purpose and may trigger risky handler behavior on the host system.
elif sys.platform.startswith('darwin'):
subprocess.run(['open', str(out_path)], check=False)
else:
subprocess.run(['xdg-open', str(out_path)], check=False)
except Exception as e:
print('Failed to open image:', e)
No suspicious patterns detected.