Логотип exploitDog
Консоль
Логотип exploitDog

exploitDog

nvd логотип

CVE-2023-24538

Опубликовано: 06 апр. 2023
Источник: nvd
CVSS3: 9.8
EPSS Низкий

Уязвимость в обработке шаблонов Go, позволяющая внедрение JavaScript через неэкранированные обратные кавычки

Описание

Шаблоны некорректно обрабатывают обратные кавычки как разделители строк в JavaScript и не экранируют их должным образом. Обратные кавычки используются в ES6 для шаблонных строк в JavaScript. Если шаблон содержит действие Go-шаблона внутри литерала JavaScript, содержимое этого действия может быть использовано для завершения литерала, внедряя произвольный код JavaScript в Go-шаблон. Поскольку шаблонные строки ES6 сами по себе могут проводить интерполяцию строк, было принято решение запретить использование действий Go-шаблонов внутри них (например, "var a = {{.}}"), так как нет очевидно безопасного способа разрешить такое поведение. Это аналогичный подход, который использует github.com/google/safehtml. После исправления Template.Parse возвращает ошибку при обнаружении подобных шаблонов с кодом ошибки 12. Этот код ошибки в настоящий момент не экспортируется, но будет экспортирован в релизе Go 1.21. Пользователи, которые полагаются на предыдущее поведение, могут восстановить его с помощью флага GODEBUG jstmpllitinte.

Затронутые версии ПО

  • Go до релиза 1.21

Тип уязвимости

Выполнение произвольного кода

Уязвимые конфигурации

Конфигурация 1

Одно из

cpe:2.3:a:golang:go:*:*:*:*:*:*:*:*
Версия до 1.19.8 (исключая)
cpe:2.3:a:golang:go:*:*:*:*:*:*:*:*
Версия от 1.20.0 (включая) до 1.20.3 (исключая)

EPSS

Процентиль: 70%
0.00646
Низкий

9.8 Critical

CVSS3

Дефекты

CWE-94
CWE-94

Связанные уязвимости

CVSS3: 9.8
ubuntu
больше 2 лет назад

Templates do not properly consider backticks (`) as Javascript string delimiters, and do not escape them as expected. Backticks are used, since ES6, for JS template literals. If a template contains a Go template action within a Javascript template literal, the contents of the action can be used to terminate the literal, injecting arbitrary Javascript code into the Go template. As ES6 template literals are rather complex, and themselves can do string interpolation, the decision was made to simply disallow Go template actions from being used inside of them (e.g. "var a = {{.}}"), since there is no obviously safe way to allow this behavior. This takes the same approach as github.com/google/safehtml. With fix, Template.Parse returns an Error when it encounters templates like this, with an ErrorCode of value 12. This ErrorCode is currently unexported, but will be exported in the release of Go 1.21. Users who rely on the previous behavior can re-enable it using the GODEBUG flag jstmplliti...

CVSS3: 9.8
redhat
больше 2 лет назад

Templates do not properly consider backticks (`) as Javascript string delimiters, and do not escape them as expected. Backticks are used, since ES6, for JS template literals. If a template contains a Go template action within a Javascript template literal, the contents of the action can be used to terminate the literal, injecting arbitrary Javascript code into the Go template. As ES6 template literals are rather complex, and themselves can do string interpolation, the decision was made to simply disallow Go template actions from being used inside of them (e.g. "var a = {{.}}"), since there is no obviously safe way to allow this behavior. This takes the same approach as github.com/google/safehtml. With fix, Template.Parse returns an Error when it encounters templates like this, with an ErrorCode of value 12. This ErrorCode is currently unexported, but will be exported in the release of Go 1.21. Users who rely on the previous behavior can re-enable it using the GODEBUG flag jstmplliti...

CVSS3: 9.8
debian
больше 2 лет назад

Templates do not properly consider backticks (`) as Javascript string ...

CVSS3: 9.8
github
больше 2 лет назад

Templates do not properly consider backticks (`) as Javascript string delimiters, and do not escape them as expected. Backticks are used, since ES6, for JS template literals. If a template contains a Go template action within a Javascript template literal, the contents of the action can be used to terminate the literal, injecting arbitrary Javascript code into the Go template. As ES6 template literals are rather complex, and themselves can do string interpolation, the decision was made to simply disallow Go template actions from being used inside of them (e.g. "var a = {{.}}"), since there is no obviously safe way to allow this behavior. This takes the same approach as github.com/google/safehtml. With fix, Template.Parse returns an Error when it encounters templates like this, with an ErrorCode of value 12. This ErrorCode is currently unexported, but will be exported in the release of Go 1.21. Users who rely on the previous behavior can re-enable it using the GODEBUG flag jstmplliti...

CVSS3: 9.8
fstec
больше 2 лет назад

Уязвимость пакета golang операционной системы Debian GNU/Linux, позволяющая нарушителю выполнить произвольный код

EPSS

Процентиль: 70%
0.00646
Низкий

9.8 Critical

CVSS3

Дефекты

CWE-94
CWE-94