T07 · Tool Hijacking and Spoofing
- Location
scripts/record_health_data.py:71- Finding
PATH-Based Hijacking of the mcporter Executable
- Content
View full analysis
Vulnerability Details
File Location:
scripts/record_health_data.py, lines 71-78
Vulnerability Type: Untrusted executable resolution through the inheritedPATH
Risk Level: MediumVulnerable Code
python cmd = [ 'mcporter', '--config', '/Users/klcintw/clawd/config/mcporter.json', 'call', 'ax3-personal.record_habit', f'habitId={habit_id}', f'numberValue={value}' ] result = subprocess.run(cmd, capture_output=True, text=True, check=True)Technical Analysis
The subprocess invocation uses the bare executable name
mcporter. Python therefore delegates executable resolution to the operating system using the process's inheritedPATH.Although the code safely avoids
shell=Trueand constructs the arguments as a list, those protections do not prevent executable-path hijacking. If an attacker can modifyPATH, control a directory already listed before the legitimate executable, or place a counterfeitmcporterbinary in a writable search directory, the counterfeit program will be executed.The fixed configuration argument does not mitigate this issue because it is passed directly to whichever executable is resolved first. A counterfeit executable could also imitate valid JSON output, making the invocation appear successful.
Attack Path
- An attacker obtains write access to a directory that precedes the legitimate
mcporterinstallation directory in the Agent process'sPATH, or causes the Skill to run with an attacker-controlledPATH. - The attacker places an executable file named
mcporterin that directory. - A user message containing a supported health measurement causes
record_to_ax3to run. subprocess.runresolvesmcporterthroughPATHand starts the attacker's executable.- The counterfeit executable runs with the same operating-system identity and permissions as the Agent process.
- It may access Agent-readable data, alter healt ...[truncated 671 chars]
- An attacker obtains write access to a directory that precedes the legitimate
- Remediation
View remediation
Remediation Suggestions
- Invoke
mcporterthrough an absolute path located in an administrator-controlled directory rather than relying onPATH. - During deployment, verify that the executable is owned by a trusted account and is not writable by unprivileged users.
- If dynamic discovery is unavoidable, resolve the executable once with
shutil.which, verify the resolved path against an explicit allowlist, and reject unexpected locations. - Supply a minimal, trusted environment to
subprocess.run, including a restrictedPATH. - Run the Skill under a dedicated least-privileged account with access only to the required AX3 configuration and API operation.
- Where supported, verify the executable's signature or expected cryptographic digest before execution.
- Invoke
