logoalt Hacker News

Forgejo <=16.0.3 Critical RCE

130 pointsby weierstasstoday at 3:57 PM48 commentsview on HN

Comments

amiga386today at 5:15 PM

You should change the URL to 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.

show 1 reply
techknowlogicktoday at 6:02 PM

Only posting here because I've been asked about it. Gitea is protected against both of these issues.

(bias note: part of project leadership of Gitea)

Edit: As a note, security incidents happen to everyone and we shouldn't shame anyone for reporting them, especially as that'd otherwise cause less issues to be reported overall.

show 3 replies
keel-controltoday at 5:38 PM

This was my first thought after they disallowed LLM contributions.

They may not use AI to check for vulnerabilities but attackers are going to which puts themselves at the disadvantage.

show 5 replies
Machatoday at 5:16 PM

Since the release notes is currently unreadable due to codeberg rate limits, the two fixes in the release notes are:

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 restrictions, such as repo-specific access tokens. As a result, it was possible for an API access token with restricted permission to make modifications outside of that restricted permission. The specialized security control has been updated to take into account API authentication security restrictions.

---

So if like me you run a private forgejo instance with closed signups and limited repository creation, you can wait for the update. Otherwise maybe take it off the public internet for a bit?

jzebedeetoday at 5:14 PM

Relevant change:

   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.
show 1 reply
rclevengtoday at 5:10 PM

``` This git endpoint is seeing a high influx of requests for this repository, to preserve the availability of Codeberg your search request will not be processed. Sorry for the inconvenience and please try again later. ```

Any mirror?

show 2 replies
mmsctoday at 8:05 PM

Wonder how long it took from report to patch. IME codeberg has one of the rudest security teams in oss (fair enough or not, irrelevant). https://news.ycombinator.com/item?id=47941590 Is quite relevant

show 2 replies
miguelgrinbergtoday at 6:45 PM

For those on version 15 LTS, this fix was released with v15.0.8.

innocent_nametoday at 6:18 PM

The opex and security fine costs of moving off managed services like GitHub/GitLab are catching up.

PaoloBarbolinitoday at 5:15 PM

If you are self-hosting Forgejo and haven't done it yet, consider creating a Codeberg account and following https://codeberg.org/forgejo/security-announcements/issues

show 1 reply
nightpooltoday at 6:27 PM

What does the error message mean by "Your search request"? Why is viewing a single file in a repository considered a search request? That smells like poor caching somewhere

Sphaxtoday at 5:15 PM

Can't load the page but hopefully it's on an endpoint sitting behind my Tinyauth protection.

dborehamtoday at 6:18 PM

Quick note that this is not an RCE in the typical sense that I can rock up to a Forgejo installation and execute code on the server. The attack vector here is via a template repo specified when initializing a new repo. The template repo could contain malicious code that then executes on the host server. So if you don't create new repos from mystery meat template repos, you should be ok.

show 2 replies
rvztoday at 6:57 PM

As I said before for patching vulnerabilities in the age of AI [0], attackers are going to build exploits around this RCE with AI or even find more flaws with AI.

This means you have no choice but to use AI to defend, find and patch these flaws before attackers quickly build and use these exploits to target users.

You cannot afford to disallow or have a 100% ban on LLM contributions while attackers do not care and will use AI to find the flaws and attack you faster than you can triage it.

[0] https://news.ycombinator.com/item?id=49262849

bakugotoday at 6:28 PM

Trying to open any codeberg.org page from my main Helium browser results in a 403 just saying "Bye". Opening in Chrome or Firefox works fine. Very confusing.

vyftec_wpsectoday at 7:19 PM

[flagged]