T09 · Insecure Skill Coding Practices
- Location
setup-oauth.js:45- Finding
OAuth Authorization Response Is Not Protected by State Validation
- Content
View full analysis
{ const url = new URL(req.url, `http://${req.headers.host}`); if (url.pathname === '/callback') { const code = url.searchParams.get('code'); const error = url.searchParams.get('error'); ``` ```javascript const tokenResponse = await fetch('https://api.dropboxapi.com/oauth2/token', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams({ code, grant_type: 'authorization_code', client_id: app_key, client_secret: app_secret, redirect_uri: REDIRECT_URI, }), }); ``` ### Technical Analysis The authorization request does not contain a cryptographically random OAuth `state` parameter. The callback consequently cannot verify that the received authorization response corresponds to the authorization flow initiated by the local user. The callback accepts any syntactically valid `code` and immediately exchanges it using the configured application credentials. This creates an OAuth authorization-response injection or login-CSRF condition. The project documentation acknowledges that state management would be needed for production, but the setup script itself remains unprotected. PKCE is also absent. Although PKCE does not replace `state` for all CSRF protections, using both controls would provide stronger binding between the auth ...[truncated 1230 chars]- Remediation
View remediation
