fix(security): prevent open redirect from user-controlled data (SonarQube jssecurity:S5146) - #228
Conversation
…urity:S5146) Co-Authored-By: Joao Esteves <joao.esteves@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
SonarQube remediation — issue What was vulnerable: What changed: added Scope: one file, +9/−1. No refactoring, reformatting, or other vulnerability fixes; the SonarQube issue status was not modified. |
Summary
adminLoginSuccessinroutes/index.jsredirected straight toredirectPage, which comes fromreq.body.redirectPageon the admin login POST. An attacker could send a victim to/login?redirectPage=https://evil.[REDACTED SECRET](or//evil.[REDACTED SECRET]) and have the app bounce them off-site after login — a classic open redirect used for phishing/credential harvesting.Fix restricts the target to same-origin relative paths only, falling back to
/admin:This rejects absolute URLs (
https://evil.[REDACTED SECRET]), protocol-relative URLs (//evil.[REDACTED SECRET]) and backslash variants (/\evil.[REDACTED SECRET]) that some browsers normalize to a host.SonarQube issue:
AZhSVLrd4wErqc9Ey1Y4— rulejssecurity:S5146,routes/index.js:61, severity BLOCKER. No other code was touched.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/b20590b053fc45e69fc0f66ee592c206
Requested by: @joao-cognition
Note
Devin errored when opening this Pull Request as joao-cognition.
As a fallback, Devin opened this PR as itself.
Devin Review