T09 · Insecure Skill Coding Practices
- Location
scripts/render-gotchi-sprite.mjs:324- Finding
Path Traversal Through an Unvalidated JSON-Supplied Gotchi ID
- Content
View full analysis
({ trait_type: attr.trait_type, value: attr.trait_type === "Base Body" ? normalizeCollateral(attr.value) : attr.trait_type === "Eye Shape" ? normalizeEyeShape(attr.value) : attr.trait_type === "Eye Color" ? normalizeEyeColor(attr.value) : attr.trait_type.startsWith("Wearable") ? normalizeWearableName(attr.value) : attr.value })) : []; if (!attributes.some((attr) => attr.trait_type === "Eye Color")) { const eyeShape = attributes.find((attr) => attr.trait_type === "Eye Shape")?.value || ""; const fallbackEyeColor = defaultEyeColorForShape(eyeShape); if (fallbackEyeColor) { attributes.push({ trait_type: "Eye Color", value: fallbackEyeColor }); } } return { ...gotchi, collateral: normalizeCollateral(gotchi.collateral), attributes }; } ``` ```js function loadGotchi(args) { if (args.help) { printHelp(); process.exit(0); } if (args.input) { const inputPath = path.resolve(process.cwd(), requireString(args.input)); return normalizeGotchiPayload(JSON.parse(fs.readFileSync(inputPath, "utf8"))); } return buildGotchiFromFlags(args); } ``` ```js const gotchi = loadGotchi(args); const outputDir = path.resolve( process.cwd(), requireString(args["output-dir"], `./output/${slug}`) ); fs.mkdirSync(outputDir, { recursive: true }); const generatedPath = path.join(outputDir, `${gotchi.id}.png`); const rawSpritePath = path.join(outputDir, `${gotchi.id}.raw.png`); const finalSpritePath = ...[truncated 2874 chars]- Remediation
View remediation
