T09 · Insecure Skill Coding Practices
- Location
index.js:48- Finding
Path Traversal Through Unvalidated Genre Argument
- Content
View full analysis
{ console.error(err); process.exit(1); }); ``` ### Technical Analysis The value following `--genre` is accepted directly from the command line and interpolated into a filesystem path. The code does not restrict the value to the keys in `GENRES`, remove path separators, or verify that the resolved destination remains inside `TALES_DIR`. Although `path.join()` normalizes paths, it does not prevent traversal. A genre containing components such as `../` can cause the resulting filename to resolve outside `../../memory/tales`. The appended timestamp prevents an attacker from choosing the exact final filename, but it does not prevent unauthorized file creation in another writable directory. The story body also incorporates the supplied genre, allowing the attacker to influence part of the written content. ### Attack Path 1. An attacker obtains the ability to invoke the skill or influence its command-line arguments. 2. The attacker supplies a genre containing traversal components, for example: ```bash node index.js --genre ". ...[truncated 1094 chars]- Remediation
View remediation
