T09 · Insecure Skill Coding Practices
- Location
references/upload.md:153- Finding
Copy-ready upload examples transmit user-selected files to a fixed third-party endpoint
- Content
View full analysis
``` The custom upload example explicitly sends the selected local file to the same service: ```ts const action = 'https://mockapi.eolink.com/zhTuw2P8c29bc981a741931bdd86eb04dc1e8fd64865cb5/upload' const customUpload: UploadMethod = (file, formData, options) => { const uploadTask = uni.uploadFile({ url: action, header: options.header, name: options.name, fileName: options.name, fileType: options.fileType, formData, filePath: file.url, success(res) { if (res.statusCode === options.statusCode) { options.onSuccess(res, file, formData) } else { options.onError({ ...res, errMsg: res.errMsg || '' }, file, formData) } }, fail(err) { options.onError(err, file, formData) } }) uploadTask.onProgressUpdate((res) => { options.onProgress(res, file) }) } ``` The image-cropper example also uploads the generated image to that endpoint: ```ts await startUpload(file, { action: 'https://mockapi.eolink.com/zhTuw2P8c29bc981a741931bdd86eb04dc1e8fd64865cb5/upload', onSuccess() { imgSrcUpload.value = tempFilePath showToast({ msg: t('shang-chuan-cheng-gong') }) } ...[truncated 2632 chars]- Remediation
View remediation
``` Require an explicit confirmation before transmitting selected content. 4. Move the destination into application configuration rather than embedding it in reusable source code: ```ts const action = import.meta.env.VITE_UPLOAD_ENDPOINT ``` 5. Require production upload endpoints to implement: - Authentication and authorization - HTTPS with certificate validation - File size and type allowlists - Server-side content validation - Malware scanning where appropriate - Randomized server-side file names - Storage access controls and retention limits - Rate limiting and audit logging 6. Avoid logging file contents, sensitive form data, authentication headers, or private upload responses. 7. Update the Skill instructions to require safe placeholders and privacy warnings whenever generating examples that transmit user-selected files. 8. Replace the endpoint in both `references/upload.md` and `references/imgCropper.md`, then search the entire reference set to ensure no remaining examples send user data to uncontrolled demonstration services. ]]>
