T09 · Insecure Skill Coding Practices
- Location
dndcharactergenerator.js:4- Finding
API Token Can Be Misclassified and Transmitted as Image Prompt Data
- Content
View full analysis
!a.startsWith('--')) || 'DnD fantasy character portrait, detailed armor and weapons, dramatic lighting, epic fantasy art style, highly detailed character design, tabletop RPG hero'; const tokenIndex = args.indexOf('--token'); const tokenFlag = tokenIndex !== -1 ? args[tokenIndex + 1] : null; ``` The resulting value is subsequently inserted into the API request body: ```js const body = { storyId: 'DO_NOT_USE', jobType: 'universal', rawPrompt: [{ type: 'freetext', value: PROMPT, weight: 1 }], width, height, meta: { entrance: 'PICTURE,VERSE' }, context_model_series: '8_image_edit', }; ``` The README explicitly documents a prompt-free invocation at `README.md:29`: ```bash node dndcharactergenerator.js --token YOUR_TOKEN ``` ### Technical Analysis The program identifies the prompt by selecting the first command-line argument that does not begin with `--`. This logic does not distinguish positional arguments from values belonging to named options. For the documented command `node dndcharactergenerator.js --token YOUR_TOKEN`, the argument array contains `--token` followed by `YOUR_TOKEN`. Because the token value does not begin with `--`, it is selected as `PROMPT`. The same value is also correctly selected as `TOKEN`. As a result, the credential is transmitted both as the authentication header and as the image-generation prompt: ```js const HEADERS = { 'x-token': TOKEN, 'x-platform': 'nieta-app/web', 'content-type': 'application/json', }; ``` Prompt data may be handled by additional backend components such as moderation, generation, telemetry, debugging, or prompt-retention systems. This unnecessarily e ...[truncated 1148 chars]- Remediation
View remediation
