В Forgejo нашли критическую RCE: вредоносный шаблон даёт доступ к хосту

Forgejo <=16.0.3 Critical RCE

В Forgejo версий 16.0.3 и ниже обнаружили критическую уязвимость удалённого выполнения кода. При создании репозитория из шаблона Forgejo клонирует его, удаляет папку .git, раскрывает переменные в файлах из .forgejo/template и заново инициализирует git. Через раскрытие переменных атакующий может создать новую папку .git, которую git подхватит при инициализации, — так вредоносный шаблон позволяет читать произвольные данные и выполнять команды на хосте. Исправление удаляет любую папку .git после раскрытия переменных.

Вредоносный шаблонный репозиторий мог использоваться для чтения произвольных данных с хоста Forgejo и выполнения произвольных процессов на хосте Forgejo в рамках атаки удалённого выполнения кода.
  1. amiga386

    Тебе стоит изменить URL на https://codeberg.org/forgejo/forgejo/milestone/139655

    > PR: Critical: fix: prevent template expansion from interfering with git repo initialization. When generating a new repository from a template repository, Forgejo clones the template repository, removes the .git folder, performs variable template expansion on files listed in .forgejo/template, and initializes a new git repository. During this process, variable template expansion could be misused in order to create a new .git folder, which git would adopt and incorporate during its initialization of a new git repository. A malicious template repository could be used to read arbitrary data from the Forgejo host, and to execute arbitrary processes on the Forgejo host, as a remote code execution attack. To address this issue, after variable expansion is completed, any existing .git folder is removed from the directory before the git repository is initialized.

  2. techknowlogick

    Пишу здесь только потому, что меня об этом спросили. Gitea защищена от обеих этих проблем.

    (примечание о предвзятости: я вхожу в руководство проекта Gitea)

    Edit: Отмечу, что инциденты безопасности случаются со всеми, и мы не должны стыдить никого за их сообщение, особенно потому, что иначе в целом будет сообщаться меньше проблем.

  3. keel-control

    Это была моя первая мысль после того, как они запретили вклад от LLM.

    Они могут не использовать ИИ для проверки на уязвимости, но атакующие будут, что ставит их в невыгодное положение.

  4. Macha

    Поскольку примечания к выпуску сейчас нечитаемы из-за ограничений скорости на codeberg, вот два исправления из примечаний к выпуску:

    https://codeberg.org/forgejo/forgejo/pulls/14301:

    *Critical:* fix: prevent template expansion from interfering with git repo initialization. When generating a new repository from a template repository, Forgejo clones the template repository, removes the `.git` folder, performs variable template expansion on files listed in `.forgejo/template`, and initializes a new git repository. During this process, variable template expansion could be misused in order to create a new `.git` folder, which git would adopt and incorporate during its initialization of a new git repository. A malicious template repository could be used to read arbitrary data from the Forgejo host, and to execute arbitrary processes on the Forgejo host, as a remote code execution attack. To address this issue, after variable expansion is completed, any existing `.git` folder is removed from the directory before the git repository is initialized.

    https://codeberg.org/forgejo/forgejo/pulls/14301:

    ensure authorization reducer is accessed when checking editable PRs in APIs. When editing a git repo contents through Forgejo's API, a specialized security control is used to permit repository maintainers to edit branches that they do not own when an open pull request with the "allow maintainer edit" option is present. This specialized security control did not take into account API-specific security res […]

  5. jzebedee

    Соответствующее изменение:

    Security bug fixes

    PR: Critical: fix: prevent template expansion from interfering with git repo initialization. When generating a new repository from a template repository, Forgejo clones the template repository, removes the .git folder, performs variable template expansion on files listed in .forgejo/template, and initializes a new git repository. During this process, variable template expansion could be misused in order to create a new .git folder, which git would adopt and incorporate during its initialization of a new git repository. A malicious template repository could be used to read arbitrary data from the Forgejo host, and to execute arbitrary processes on the Forgejo host, as a remote code execution attack. To address this issue, after variable expansion is completed, any existing .git folder is removed from the directory before the git repository is initialized.

Ещё за этот день

2026-09-10