Skip to content
CodeFloe

Defense & Protection Measures

We have witnessed the historic attacks on the Codeberg infrastructure, primarily through DDOS attacks (on the technical side) and user spam (on the moderation side). DDOS is hard to prevent in the first place, even with active support rails from the underlying cloud provider. It highly depends on the magnitude of the attack whether it will be classified as “DDOS” or just as “heavy traffic”.

We want to be frank and open here: we can’t say what will happen until the first attack has landed ;)

In general, there are many ways one can attack a public service. We are trying our best to put practices in place that prevent unauthorized access, resource abuse and other known risk factors, such as SQL injection attacks and cross-site scripting (XSS) attacks. This goes in line with a clear and transparent RBAC-system for all satellite-services in place which can eventually have an influence on the primary instance and its data.

Following HAProxy’s bot protection guidelines, we have implemented a multi-layered defense system with the following measures:

These limits apply to everyone, whether signed in, using an access token, or anonymous:

  • Per IP address: 10,000 requests per 30 minutes (about 5.5 requests per second sustained). Git over HTTPS, the container and package registries, and CI runner traffic do not count towards it.
  • Per network (/16 for IPv4, /64 for IPv6): 100,000 requests per 30 minutes, which catches bot swarms that spread their requests over many addresses of one network.
  • Server errors: an IP address whose requests cause more than 50 server errors (5xx) within 5 minutes is paused.
  • Login and two-factor forms: 20 POST requests per IP address and form within 3 minutes.
  • Filtered issue and pull request lists (by label, milestone, author, assignee, project or sort order): 600 requests per IP address within 10 minutes.
  • CI runners: 6,000 requests per minute per IP address, so many runners behind one NAT still fit.

Visitors who are not signed in get lower budgets on expensive pages, such as filtered issue lists, commits at a specific hash, archives of a pinned commit and feeds, in addition to the browser check. API clients also have an hourly budget per account and a limit on repeated issue and pull request lists, see API Clients.

  • Brute force attack prevention for login endpoints (more than 20 POST requests to a login form within 3 minutes)
  • WordPress/CMS attack blocking for common attack vectors (/wp-admin/, /wordpress/)
  • Bot persistence tracking that tags and continues blocking suspected bots until stick-table expiration
  • User-Agent based detection blocking known malicious bots (semrus, AhrefsBot, MJ12bot, ZoominfoBot, DotBot, MauiBot, BacklinksExtendedBot, BLEXBot, Barkrowler, SeznamBot, DataForSeoBot, IbouBot, serpstatbot, facebookexternalhit, l9explore, PerplexityBot, meta-webindexer, meta-externalagent, AwarioBot, NRC Audio, CensysInspect, NexusSearchBot, Scrapy, among others)
  • Outdated browser blocking for Chrome, Edge, Chrome on iOS, and Firefox versions older than about three months (see Outdated Browsers)
  • Current Firefox ESR releases and the Android System WebView are exempt from the version check
  • Discontinued browser engines (Internet Explorer/Trident and Presto-based Opera) are blocked outright
  • IP-based blocking using curated lists from the Ultimate Hosts Blacklist project
  • A short browser check for visitors who are not signed in, on pages crawlers abuse (see Browser Check)
  • HSTS enforcement with 2-year max-age, subdomain inclusion, and preload directive
  • Anti-clickjacking protection via X-Frame-Options
  • MIME type sniffing prevention through X-Content-Type-Options
  • Secure cookie enforcement with Secure and SameSite=Lax attributes
  • Privacy protection including FLoC opt-out
  • Request header sanitization removing client-provided IP headers to prevent spoofing

On top, we also have a dedicated allowlist for “good bots”. These are helpful to let projects be found by search engines and alikes. We are using a curated list from “AnTheMaker/GoodBots” for that.

Some pages are expensive for us to generate and attract crawlers that try to copy everything on a site. For visitors who are not signed in, CodeFloe puts such pages behind a short browser check. You see a page titled “Checking your browser”, and about two seconds later the page you asked for loads by itself. There is nothing to click or solve.

  • Only when you are not signed in. Signed-in users never see the check.
  • Always on a few kinds of pages that crawlers abuse and people rarely open, such as filtered issue and pull request lists and files viewed at a specific commit.
  • For a while on other pages, when CodeFloe or a single repository receives unusually heavy traffic from visitors who are not signed in. It switches off again by itself once the traffic drops.
  • After you pass, you do not see it again for 24 hours.
  • The check page contains a small image. Loading it gives your browser a cookie, and with that cookie the page you asked for loads.
  • It needs no JavaScript, solves no puzzle and uses no third-party service.
  • The cookie only holds a token derived from your network and a secret on our servers. It does not identify you and is not used for tracking.
  • The token covers your whole network, so it keeps working when your address changes within it, for example on a mobile connection.
  • Crawlers that copy sites in bulk usually fetch only the HTML and never load images, so they never get the cookie.

Tools such as curl do not get the check page. On the pages that require the check, they get a 403 response instead. Use the API with an access token for automation (see API Clients). Cloning, downloading archives and releases, and the package registry never require the check.

  • Allow images and cookies for codefloe.com. Some privacy extensions and strict browser settings block one of them.
  • Sign in, which skips the check entirely.
  • If you keep returning to the check page, please report it on the forum together with your browser and any extensions that block content.

Requests with an access token count towards the limits in Rate Limiting & Traffic Control like any other request. On top of that, each account has an hourly API budget, and repeated issue and pull request lists have a limit of their own.

Each account can make 5,000 API requests per hour, and those requests can take up to 30 minutes of server time per hour.

  • All of an account’s access tokens and OAuth grants share one budget, including tools such as CI servers that call the API on the account’s behalf.
  • It counts signed-in requests to /api/v1, and downloads of raw files, archives, attachments and release assets made with a token.
  • Anonymous requests, the web interface, Git over HTTPS, LFS, the package registries and the built-in token of Forgejo Actions jobs do not count.
  • Server time is the time the server spends answering a request, at most 60 seconds per request, so a few slow requests can use up the budget before the request count does.
  • The hour starts on the full hour (UTC), and the budget resets completely when it ends.

Every counted response reports the budget in its headers:

Header Meaning
X-RateLimit-Limit Requests allowed per hour.
X-RateLimit-Remaining Requests left this hour, 0 when the server time is used up.
X-RateLimit-Used Requests made this hour.
X-RateLimit-Reset When the hour ends, as a Unix timestamp.
X-RateLimit-Cost-Limit Server time allowed per hour, in milliseconds.
X-RateLimit-Cost-Remaining Server time left this hour, in milliseconds.

When the budget is used up, API requests get a 429 JSON response with a Retry-After header holding the seconds until the next hour. The request and server-time numbers follow GitHub’s REST API headers, so clients that already respect GitHub’s limits slow down here too.

If your workload needs more, ask on the forum and describe what it does.

Issue and pull request lists (API paths ending in /issues or /pulls) are also limited per token and URL:

  • Each token can request the same list URL, including its query string, 30 times within 10 minutes.
  • The 31st request gets a 429 JSON response with a Retry-After: 600 header.
  • Different pages, filters, repositories and tokens count separately, so paging through a long list or a Renovate run is not affected.
  • Requests that got a 429 count too, so retrying right away keeps the list blocked.
  • Fetch the same list at most every 20 seconds, and reuse the result inside your tool instead of requesting the same list from several places.
  • Use webhooks to react to new or changed issues and pull requests instead of polling.
  • Ask only for what changed, for example with the since parameter of the issue list.
  • Read X-RateLimit-Remaining and slow down before it reaches 0, instead of waiting for a 429.
  • After a 429, wait for the time in Retry-After before trying again.

The MCP server has its own limit of 300 requests per minute per token.

If your browser reports an old version, CodeFloe answers with a 403 Browser Update Required page instead of the page you asked for. This is not because CodeFloe is vulnerable to old browsers. It is one of the most effective defences we have against scrapers.

Most of the abusive crawling traffic we see sends a User-Agent header claiming to be a Chrome release that is several months old. These crawlers rotate through thousands of IP addresses, often from residential proxy pools, so rate limits per IP cannot catch them. The browser version they claim, however, stays the same across all of those addresses. Real browsers update themselves automatically within days to a few weeks, so almost no person is still on a release that old. In our traffic analysis, the requests below the threshold were nearly all single requests from addresses we never saw again, while the requests from current versions looked like normal browsing sessions.

  • Chrome, Edge, Chrome on iOS, and other Chromium-based browsers (Brave, Vivaldi, Opera, …) are accepted if their major version was already the stable release about three months ago or is newer.
  • Firefox follows the same three-month rule.
  • The Firefox ESR lines Mozilla currently supports are always accepted.
  • Android System WebView, the in-app browser many Android apps open links in, is not checked, because it updates separately from Chrome and often lags behind it.
  • Safari and other browsers that do not identify as Chrome or Firefox are not checked.
  • Internet Explorer and the old Presto-based Opera are always blocked.

The thresholds are recalculated from Google’s and Mozilla’s release feeds on every deploy, and the error page shows the minimum versions currently in effect.

If you see the page with an up-to-date browser

Section titled “If you see the page with an up-to-date browser”

The check only looks at the version your browser sends in its User-Agent header. If you are sure your browser is current, something is probably changing that header:

  • Privacy extensions and user-agent switchers often send a fixed, older browser version. Turn them off for codefloe.com, or set them to report your real version.
  • Some corporate proxies and security products rewrite the header.
  • Browsers that are no longer updated on your operating system (for example Chrome on Windows 7 or old macOS versions) are blocked by design. Switching to Firefox ESR is usually the easiest way out.

If none of this applies, please report it on the forum and include the User-Agent your browser sends, which you can see on sites such as https://www.whatismybrowser.com.

Git over SSH is reached on port 22 (proxied by HAProxy to OpenSSH sshd, which also accepts shell connections directly on port 2222). The SSH transport is hardened on two layers:

  • OpenSSH hardening — MaxAuthTries 20 per connection and LoginGraceTime 60s cap how much a single attacker can extract from one handshake.
  • fail2ban watching the systemd sshd journal with four layered jails, all banning at the firewall via firewalld rich rules:
    • sshd — 5 failed auths in 10 min → 1 h ban (everyday brute-force)
    • sshd-aggressive — 10 in 5 min → 24 h ban (active scanners)
    • sshd-ddos — 20 in 1 min → 2 h ban (connection floods)
    • sshd-long-term — 15 in 1 h → 24 h ban (slow persistent attackers)

Bans persist across reboots via a sqlite-backed state file, and internal subnets plus known-good IPs are allowlisted so CI agents and internal tooling are never affected.

Legitimate users with several SSH keys loaded in their ssh-agent can accidentally trip the sshd jail, because OpenSSH offers every loaded key in turn and each one the server does not recognise counts as a failed attempt. See SSH Access for the recommended client configuration that avoids this.