Fix for SECURITY-2979 / CVE-2023-50771#261
Fix for SECURITY-2979 / CVE-2023-50771#261michael-doubez merged 2 commits intojenkinsci:masterfrom eHealthExperts:bugfix/gh-issue-259-open-redir-vuln
Conversation
Sanitize redirect url to make sure it cannot point wherever the from query parameter shows.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #261 +/- ##
============================================
- Coverage 71.21% 70.46% -0.75%
Complexity 190 190
============================================
Files 9 9
Lines 740 745 +5
Branches 122 124 +2
============================================
- Hits 527 525 -2
- Misses 153 160 +7
Partials 60 60 ☔ View full report in Codecov by Sentry. |
| } | ||
| } | ||
| // If the URL is null, empty, or invalid, return the root URL | ||
| return getRootUrl(); |
There was a problem hiding this comment.
Root URL is not always correctly setup (typicallty localhost on k8s deployments) and people rely on referer to deduce the correct URL as seen by the user.
There was a problem hiding this comment.
See my comment in the issue, please. The referer is passed in when calling the function.
michael-doubez
left a comment
There was a problem hiding this comment.
Please use referer if not empty.
|
Hello @michael-doubez , thank you for your feedback. The referer is already passed in when the validation method is being called. The precedence is the same as before: |
|
I've added a test yet, but I cannot figure out how to determine the dynamic port of the wireMockRule. Hints appreciated. It has a constructor that accepts the rootUrl as string and I wanted to use that one but it was ignored in github ci. |
Hi, this fixes the open redirect vulnerability of #259 by validating. I've patched that for our internal use and I didn't work on the other open CVE because from my understanding it's only relevant if you enable this fallback user functionality which is not relevant for us. I thought it might still make sense to propose this here so others can quickly patch it for themselves or just use our fork release.
Please forgive me for not writing a test. I just wanted to share the fix to make the world a better place with the little time I have. Feel free to steal my code and do it properly.
Testing done
I manually tested this following these steps:
https://jenkins.example.com/securityRealm/commenceLogin?from=https://google.com