T09 · Insecure Skill Coding Practices
- Location
script/douyin-parse.cjs:38- Finding
Unrestricted HTTP Requests and Redirects Enable Server-Side Request Forgery
- Content
View full analysis
{ if (!url.includes('v.douyin.com')) { resolve(url); return; } const parsedUrl = new URL(url); const isHttps = parsedUrl.protocol === 'https:'; const client = isHttps ? https : http; const options = { headers: { 'User-Agent': USER_AGENT }, timeout: 10000 }; const req = client.request(url, options, (res) => { // Check for a redirect if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { console.log('Redirect found:', res.headers.location); // Recursively process the redirect resolveShortUrl(res.headers.location).then(resolve); } else { resolve(res.responseUrl || url); } }); ``` ```js function fetch(url, options = {}) { return new Promise((resolve, reject) => { const parsedUrl = new URL(url); const isHttps = parsedUrl.protocol === 'https:'; const client = isHttps ? https : http; const defaultOptions = { headers: { 'User-Agent': USER_AGENT, 'Referer': REFERER, ...options.headers }, timeout: 30000 }; const req = client.get(url, defaultOptions, (res) => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => resolve(data)); }); ``` Media redirects are followed in the same unrestricted manner: ```js const req = client.request(videoUrl, options, (res) => { // Check for a redirect if (res.s ...[truncated 3110 chars]- Remediation
View remediation
