Commit 61a9bf9
committed
Hardens custom avatar URL against email-driven URL injection
Commit emails are attacker-controllable, so identity values interpolated
into a `gitlens.remotes` `avatar` template must not be allowed to inject
URL-structural characters. `encodeUrl` uses `encodeURI`, which preserves
`/`, `?`, `#`, `@`, and `:`, so a crafted email could previously bend
the resulting avatar URL's path, query, or fragment.
- Component-encodes `${email}`, `${emailName}`, and `${domain}` before
interpolation
- Splits on the last `@` so RFC 5322 local-parts containing `@` are
preserved (and `domain` can't be truncated by a multi-`@` email)
- Drops `getContext(...)` and the outer `encodeUrl(...)` — only the four
documented tokens are relevant for an avatar URL, and every
substituted value is now pre-encoded
(#5155)1 parent 2348076 commit 61a9bf9
1 file changed
Lines changed: 16 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| |||
0 commit comments