T09 · Insecure Skill Coding Practices
Error
- Location
- export_ppt.js:69
- Finding
- Caller-Controlled Path Permits Arbitrary JavaScript Module Execution## Vulnerability Details **File Location**: `export_ppt.js`, lines 69–74 and 109–113 **Vulnerability Type**: Untrusted executable module loading **Risk Level**: High **Vulnerable code:** ```javascript if (arg === '--openmaic-path') { if (i + 1 < args.length) { OPENMAIC_PATH = args[i + 1]; i++; // Skip the next argument } else { ``` ```javascript const pptxgenPath = path.join(OPENMAIC_PATH, 'packages/pptxgenjs/dist/pptxgen.cjs.js'); let pptxgen; try { pptxgen = require(pptxgenPath); } catch (error) { ``` ### Technical Analysis The `--openmaic-path` command-line argument controls the root directory from which the script loads `pptxgen.cjs.js`. The supplied path is not restricted to a trusted installation, canonicalized and validated against an allowlist, checked for unsafe symbolic links, or verified using a cryptographic digest. A CommonJS `require()` call immediately executes the selected module's top-level JavaScript. Consequently, `--openmaic-path` is not merely a data-path parameter: it controls an executable-code source. An attacker who can influence the argument or the contents of the selected directory can execute arbitrary JavaScript with the privileges of the user or Agent running this Skill. This issue does not establish that the project itself contains malicious code. It creates a code-execution boundary through which an untrusted or compromised OpenMAIC installation can supply malicious code. ### Attack Path 1. An attacker creates or compromises a directory that appears to be an OpenMAIC installation. 2. The attacker places malicious JavaScript at `packages/pptxgenjs/dist/pptxgen.cjs.js` under that directory. 3. The attacker persuades the user or Agent to invoke the exporter with `--openmaic-path <attacker-controlled-directory>`. 4. The script constructs `pptxgenPath` beneath the supplied directory. 5. `require(pptxgenPath)` executes the attacker's module befor ...[truncated 724 chars]
- Remediation
- ## Remediation Suggestions - Declare `pptxgenjs` as a pinned dependency of this project and load it by package name from the project's own controlled dependency directory. - Commit and enforce a lockfile containing registry integrity hashes. - Do not load executable dependencies from a directory selected through a general command-line argument. - If loading from OpenMAIC is unavoidable, resolve both the installation root and module path with `fs.realpathSync()` and require them to remain under a trusted, explicitly configured canonical root. - Reject symbolic links, unexpected file ownership, and writable-by-untrusted-user module files where the deployment platform supports such checks. - Verify the module against a pinned cryptographic digest or signed manifest before calling `require()`. - Run conversion in a restricted process with minimal filesystem access, no unnecessary credentials, and no network access.
