T09 · Insecure Skill Coding Practices
- Location
scripts/doc_to_json.py:25- Finding
MinerU API Token Exposed Through Process Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/doc_to_json.py, lines 25–35
Vulnerability Type: Credential exposure through command-line arguments
Risk Level: MediumVulnerable Code
python def run_mineru(input_file: str, temp_dir: str) -> str: """Run mineru-open-api to convert document to Markdown.""" output_dir = os.path.join(temp_dir, "mineru_out") os.makedirs(output_dir, exist_ok=True) cmd = [ "mineru-open-api", "extract", "--token", os.environ.get("MINERU_TOKEN", ""), input_file, "-o", output_dir ] result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)Technical Analysis
The script reads
MINERU_TOKENfrom the environment but then places its value directly in the child process argument vector through the--tokenoption. Command-line arguments may be exposed through process-inspection facilities, process telemetry, audit systems, diagnostic tools, or logs.Consequently, another local account or monitoring component with permission to observe the MinerU process may recover the credential while extraction is running. Passing arguments as a list prevents shell command injection, but it does not protect secrets contained in those arguments.
The practical exploitability depends on the operating system's process visibility controls and the permissions of the observing user. No remote exploitation path is established by the reviewed code.
Attack Path
- A user configures a valid
MINERU_TOKENand invokesscripts/doc_to_json.py. - The script reads the secret from the environment.
- It launches
mineru-open-apiwith--token <secret>in its process arguments. - During the child process lifetime, a local attacker or telemetry component able to inspect process arguments records the command line.
- The attacker extracts and reuses the token against services accessible with that credential.
Impact Assessment
Successful expl ...[truncated 476 chars]
- A user configures a valid
- Remediation
View remediation
Remediation Suggestions
- Do not include credentials in the child process argument vector.
- Prefer allowing
mineru-open-apito readMINERU_TOKENdirectly from its inherited environment, if supported. - If environment-based authentication is unavailable, use a protected credential file or standard-input mechanism supported by MinerU. Ensure any credential file has restrictive permissions and is securely removed after use.
- Validate that
MINERU_TOKENis present before invoking the CLI and return a clear error without printing the token. - Review process-monitoring, audit, and application logs to ensure credentials from prior executions were not retained.
- Rotate any token that may already have been exposed through process inspection or telemetry.
- Document that MinerU is an external extraction service and warn users not to submit sensitive documents until they have verified its endpoint and data-handling policy.
