fix(security): prevent open redirect from user-controlled data (SonarQube jssecurity:S5146) - #222
Conversation
…be jssecurity: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:
|
|
Remediation of SonarQube issue What was wrong: What changed: added Scope: |
Summary
adminLoginSuccessinroutes/index.js:61passed the user-controlledredirectPage(fromPOST /loginbody, seeded by?redirectPage=on the login page) directly intores.redirect()— an unvalidated open redirect (SonarQubejssecurity:S5146, issueAZhSVLrd4wErqc9Ey1Y4).Attack:
POST /loginwithredirectPage=https://evil.[REDACTED SECRET]/login(or protocol-relative//evil.[REDACTED SECRET], or/\evil.[REDACTED SECRET]) sends a freshly authenticated admin to an attacker-controlled page from a trusted-looking link — phishing/credential harvesting, plusRefererleakage.Fix — allow-list of known in-app paths, everything else falls back to
/admin:An exact-match allow-list (rather than string sanitization) removes the whole bypass class: absolute URLs, protocol-relative
//host, backslash/CRLF variants andjavascript:all fail to match. Paths are the routes registered inapp.js. No other code touched; other SonarQube findings in this file are out of scope.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/1159045a948445109741d10e3c4524b7
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