Tatiana Bradley | f1409b0 | 2023-05-24 14:02:12 -0400 | [diff] [blame] | 1 | id: GO-2023-1703 |
Tatiana Bradley | b984530 | 2023-04-05 15:16:15 -0400 | [diff] [blame] | 2 | modules: |
Tatiana Bradley | 82175fd | 2023-05-31 17:04:08 -0400 | [diff] [blame] | 3 | - module: std |
| 4 | versions: |
| 5 | - fixed: 1.19.8 |
| 6 | - introduced: 1.20.0-0 |
Tatiana Bradley | 6d0cca3 | 2024-07-17 15:54:18 -0400 | [diff] [blame] | 7 | - fixed: 1.20.3 |
Tatiana Bradley | 82175fd | 2023-05-31 17:04:08 -0400 | [diff] [blame] | 8 | vulnerable_at: 1.20.2 |
| 9 | packages: |
| 10 | - package: html/template |
| 11 | symbols: |
| 12 | - tJS |
| 13 | - tJSDelimited |
| 14 | derived_symbols: |
| 15 | - Template.Execute |
| 16 | - Template.ExecuteTemplate |
Tatiana Bradley | b984530 | 2023-04-05 15:16:15 -0400 | [diff] [blame] | 17 | summary: Backticks not treated as string delimiters in html/template |
Tatiana Bradley | ccdac2d | 2023-06-22 13:27:05 -0400 | [diff] [blame] | 18 | description: |- |
Tatiana Bradley | b984530 | 2023-04-05 15:16:15 -0400 | [diff] [blame] | 19 | Templates do not properly consider backticks (`) as Javascript string |
| 20 | delimiters, and do not escape them as expected. |
| 21 | |
Tatiana Bradley | ccdac2d | 2023-06-22 13:27:05 -0400 | [diff] [blame] | 22 | Backticks are used, since ES6, for JS template literals. If a template contains |
| 23 | a Go template action within a Javascript template literal, the contents of the |
| 24 | action can be used to terminate the literal, injecting arbitrary Javascript code |
| 25 | into the Go template. |
Tatiana Bradley | b984530 | 2023-04-05 15:16:15 -0400 | [diff] [blame] | 26 | |
| 27 | As ES6 template literals are rather complex, and themselves can do string |
Tatiana Bradley | ccdac2d | 2023-06-22 13:27:05 -0400 | [diff] [blame] | 28 | interpolation, the decision was made to simply disallow Go template actions from |
| 29 | being used inside of them (e.g. "var a = {{.}}"), since there is no obviously |
| 30 | safe way to allow this behavior. This takes the same approach as |
Tatiana Bradley | b984530 | 2023-04-05 15:16:15 -0400 | [diff] [blame] | 31 | github.com/google/safehtml. |
| 32 | |
| 33 | With fix, Template.Parse returns an Error when it encounters templates like |
Tatiana Bradley | ccdac2d | 2023-06-22 13:27:05 -0400 | [diff] [blame] | 34 | this, with an ErrorCode of value 12. This ErrorCode is currently unexported, but |
| 35 | will be exported in the release of Go 1.21. |
Tatiana Bradley | b984530 | 2023-04-05 15:16:15 -0400 | [diff] [blame] | 36 | |
Tatiana Bradley | ccdac2d | 2023-06-22 13:27:05 -0400 | [diff] [blame] | 37 | Users who rely on the previous behavior can re-enable it using the GODEBUG flag |
| 38 | jstmpllitinterp=1, with the caveat that backticks will now be escaped. This |
| 39 | should be used with caution. |
Tatiana Bradley | 0910814 | 2023-05-18 16:23:32 -0400 | [diff] [blame] | 40 | credits: |
Tatiana Bradley | 82175fd | 2023-05-31 17:04:08 -0400 | [diff] [blame] | 41 | - Sohom Datta, Manipal Institute of Technology |
Tatiana Bradley | b984530 | 2023-04-05 15:16:15 -0400 | [diff] [blame] | 42 | references: |
Tatiana Bradley | 82175fd | 2023-05-31 17:04:08 -0400 | [diff] [blame] | 43 | - report: https://go.dev/issue/59234 |
| 44 | - fix: https://go.dev/cl/482079 |
| 45 | - web: https://groups.google.com/g/golang-announce/c/Xdv6JL9ENs8 |
Tatiana Bradley | b984530 | 2023-04-05 15:16:15 -0400 | [diff] [blame] | 46 | cve_metadata: |
| 47 | id: CVE-2023-24538 |
| 48 | cwe: 'CWE-94: Improper Control of Generation of Code (''Code Injection'')' |
Tatiana Bradley | bcb698b | 2023-12-05 12:33:14 -0500 | [diff] [blame] | 49 | references: |
| 50 | - https://security.gentoo.org/glsa/202311-09 |
Tatiana Bradley | 69d9a20 | 2024-05-14 15:19:00 -0400 | [diff] [blame] | 51 | review_status: REVIEWED |