Commit 4202744
url: Consistently parse URLs for isUrlOnRealm (CVE-2022-35962)
The ad-hoc parsing we'd been doing here had the consequence that it
could return true for some URL strings that in reality resolve to
URLs that aren't on the Zulip realm.
If another (authenticated) user sends a message containing an image
link crafted to trigger this bug, and the receiving user taps on the
image in order to expand it in the lightbox, this could cause the
user's login credentials to be disclosed. This is CVE-2022-35962.
To fix the issue, use `new URL` to parse the URL, the same way we're
going to do at each of its two call sites.
This still isn't a great structure, because it'd be easy for a call
site to change (or a new one to be added) so that the URL gets used
in a way other than by passing to our `new URL`, or with a different
base URL. Add a TODO to refactor accordingly, and mark the function
as deprecated to discourage new callers.1 parent d3781b2 commit 4202744
2 files changed
+32
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | 121 | | |
123 | | - | |
124 | 122 | | |
125 | | - | |
126 | 123 | | |
127 | | - | |
128 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
129 | 131 | | |
130 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
98 | 114 | | |
99 | 115 | | |
100 | 116 | | |
| |||
0 commit comments