Skip to content

Commit 5bd2aaf

Browse files
authored
Merge pull request #204 from HackTricks-wiki/update_Gitblit_CVE-2024-28080__SSH_public_key_fallback_to_20250829_182811
Gitblit CVE-2024-28080 SSH public‑key fallback to password a...
2 parents de46109 + 00730ca commit 5bd2aaf

File tree

4 files changed

+137
-7
lines changed

4 files changed

+137
-7
lines changed

src/SUMMARY.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# 🏭 Pentesting CI/CD
1010

1111
- [Pentesting CI/CD Methodology](pentesting-ci-cd/pentesting-ci-cd-methodology.md)
12+
- [Gitblit Security](pentesting-ci-cd/gitblit-security/README.md)
13+
- [Ssh Auth Bypass](pentesting-ci-cd/gitblit-security/gitblit-embedded-ssh-auth-bypass-cve-2024-28080.md)
1214
- [Github Security](pentesting-ci-cd/github-security/README.md)
1315
- [Abusing Github Actions](pentesting-ci-cd/github-security/abusing-github-actions/README.md)
1416
- [Gh Actions - Artifact Poisoning](pentesting-ci-cd/github-security/abusing-github-actions/gh-actions-artifact-poisoning.md)
@@ -537,7 +539,3 @@
537539

538540
- [HackTricks Pentesting Network$$external:https://book.hacktricks.wiki/en/generic-methodologies-and-resources/pentesting-network/index.html$$]()
539541
- [HackTricks Pentesting Services$$external:https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-ssh.html$$]()
540-
541-
542-
543-
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Gitblit Security
2+
3+
{{#include ../../banners/hacktricks-training.md}}
4+
5+
## What is Gitblit
6+
7+
Gitblit is a self‑hosted Git server written in Java. It can run as a standalone JAR or in servlet containers and ships an embedded SSH service (Apache MINA SSHD) for Git over SSH.
8+
9+
## Topics
10+
11+
- Gitblit Embedded SSH Auth Bypass (CVE-2024-28080)
12+
13+
{{#ref}}
14+
gitblit-embedded-ssh-auth-bypass-cve-2024-28080.md
15+
{{#endref}}
16+
17+
## References
18+
19+
- [Gitblit project](https://gitblit.com/)
20+
21+
{{#include ../../banners/hacktricks-training.md}}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Gitblit Embedded SSH Auth Bypass (CVE-2024-28080)
2+
3+
{{#include ../../banners/hacktricks-training.md}}
4+
5+
## Summary
6+
7+
CVE-2024-28080 is an authentication bypass in Gitblit’s embedded SSH service due to incorrect session state handling when integrating with Apache MINA SSHD. If a user account has at least one SSH public key registered, an attacker who knows the username and any of that user’s public keys can authenticate without the private key and without the password.
8+
9+
- Affected: Gitblit < 1.10.0 (observed on 1.9.3)
10+
- Fixed: 1.10.0
11+
- Requirements to exploit:
12+
- Git over SSH enabled on the instance
13+
- Victim account has at least one SSH public key registered in Gitblit
14+
- Attacker knows victim username and one of their public keys (often discoverable, e.g., https://github.com/<username>.keys)
15+
16+
## Root cause (state leaks between SSH methods)
17+
18+
In RFC 4252, public‑key authentication proceeds in two phases: the server first checks whether a provided public key is acceptable for a username, and only after a challenge/response with a signature does it authenticate the user. In MINA SSHD, the PublickeyAuthenticator is invoked twice: on key acceptance (no signature yet) and later after the client returns a signature.
19+
20+
Gitblit’s PublickeyAuthenticator mutated the session context on the first, pre‑signature call by binding the authenticated UserModel to the session and returning true ("key acceptable"). When authentication later fell back to password, the PasswordAuthenticator trusted that mutated session state and short‑circuited, returning true without validating the password. As a result, any password (including empty) was accepted after a prior public‑key "acceptance" for the same user.
21+
22+
High‑level flawed flow:
23+
24+
1) Client offers username + public key (no signature yet)
25+
2) Server recognizes the key as belonging to the user and prematurely attaches user to the session, returns true ("acceptable")
26+
3) Client cannot sign (no private key), so auth falls back to password
27+
4) Password auth sees a user already present in session and unconditionally returns success
28+
29+
## Step‑by‑step exploitation
30+
31+
- Collect a victim’s username and one of their public keys:
32+
- GitHub exposes public keys at https://github.com/<username>.keys
33+
- Public servers often expose authorized_keys
34+
- Configure OpenSSH to present only the public half so signature generation fails, forcing a fallback to password while still triggering the public‑key acceptance path on the server.
35+
36+
Example SSH client config (no private key available):
37+
38+
```sshconfig
39+
# ~/.ssh/config
40+
Host gitblit-target
41+
HostName <host-or-ip>
42+
User <victim-username>
43+
PubkeyAuthentication yes
44+
PreferredAuthentications publickey,password
45+
IdentitiesOnly yes
46+
IdentityFile ~/.ssh/victim.pub # public half only (no private key present)
47+
```
48+
49+
Connect and press Enter at the password prompt (or type any string):
50+
51+
```bash
52+
ssh gitblit-target
53+
# or Git over SSH
54+
GIT_SSH_COMMAND="ssh -F ~/.ssh/config" git ls-remote ssh://<victim-username>@<host>/<repo.git>
55+
```
56+
57+
Authentication succeeds because the earlier public‑key phase mutated the session to an authenticated user, and password auth incorrectly trusts that state.
58+
59+
Note: If ControlMaster multiplexing is enabled in your SSH config, subsequent Git commands may reuse the authenticated connection, increasing impact.
60+
61+
## Impact
62+
63+
- Full impersonation of any Gitblit user with at least one registered SSH public key
64+
- Read/write access to repositories per victim’s permissions (source exfiltration, unauthorized pushes, supply‑chain risks)
65+
- Potential administrative impact if targeting an admin user
66+
- Pure network exploit; no brute force or private key required
67+
68+
## Detection ideas
69+
70+
- Review SSH logs for sequences where a publickey attempt is followed by a successful password authentication with an empty or very short password
71+
- Look for flows: publickey method offering unsupported/mismatched key material followed by immediate password success for the same username
72+
73+
## Mitigations
74+
75+
- Upgrade to Gitblit v1.10.0+
76+
- Until upgraded:
77+
- Disable Git over SSH on Gitblit, or
78+
- Restrict network access to the SSH service, and
79+
- Monitor for suspicious patterns described above
80+
- Rotate affected user credentials if compromise is suspected
81+
82+
## General: abusing SSH auth method state‑leakage (MINA/OpenSSH‑based services)
83+
84+
Pattern: If a server’s public‑key authenticator mutates user/session state during the pre‑signature "key acceptable" phase and other authenticators (e.g., password) trust that state, you can bypass authentication by:
85+
86+
- Presenting a legitimate public key for the target user (no private key)
87+
- Forcing the client to fail signing so the server falls back to password
88+
- Supplying any password while the password authenticator short‑circuits on leaked state
89+
90+
Practical tips:
91+
92+
- Public key harvesting at scale: pull public keys from common sources such as https://github.com/<username>.keys, organizational directories, team pages, leaked authorized_keys
93+
- Forcing signature failure (client‑side): point IdentityFile to only the .pub, set IdentitiesOnly yes, keep PreferredAuthentications to include publickey then password
94+
- MINA SSHD integration pitfalls:
95+
- PublickeyAuthenticator.authenticate(...) must not attach user/session state until the post‑signature verification path confirms the signature
96+
- PasswordAuthenticator.authenticate(...) must not infer success from any state mutated during a prior, incomplete authentication method
97+
98+
Related protocol/design notes and literature:
99+
- SSH userauth protocol: RFC 4252 (publickey method is a two‑stage process)
100+
- Historical discussions on early acceptance oracles and auth races, e.g., CVE‑2016‑20012 disputes around OpenSSH behavior
101+
102+
## References
103+
104+
- [Gitblit CVE-2024-28080: SSH public‑key fallback to password authentication bypass (Silent Signal blog)](https://blog.silentsignal.eu/2025/06/14/gitblit-cve-CVE-2024-28080/)
105+
- [Gitblit v1.10.0 release notes](https://github.com/gitblit-org/gitblit/releases/tag/v1.10.0)
106+
- [Apache MINA SSHD project](https://mina.apache.org/sshd-project/)
107+
- [PublickeyAuthenticator API](https://svn.apache.org/repos/infra/websites/production/mina/content/sshd-project/apidocs/org/apache/sshd/server/auth/pubkey/PublickeyAuthenticator.html)
108+
- [RFC 4252: The Secure Shell (SSH) Authentication Protocol](https://datatracker.ietf.org/doc/html/rfc4252)
109+
110+
111+
{{#include ../../banners/hacktricks-training.md}}

src/pentesting-ci-cd/pentesting-ci-cd-methodology.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ VCS stands for **Version Control System**, this systems allows developers to **m
1212
- Gitlab
1313
- Bitbucket
1414
- Gitea
15+
- Gitblit
1516
- Cloud providers (they offer their own VCS platforms)
1617

18+
1719
## CI/CD Pipelines
1820

1921
CI/CD pipelines enable developers to **automate the execution of code** for various purposes, including building, testing, and deploying applications. These automated workflows are **triggered by specific actions**, such as code pushes, pull requests, or scheduled tasks. They are useful for streamlining the process from development to production.
@@ -101,7 +103,5 @@ Check this interesting article about the top 10 CI/CD risks according to Cider:
101103

102104
- [https://www.cidersecurity.io/blog/research/ppe-poisoned-pipeline-execution/?utm_source=github\&utm_medium=github_page\&utm_campaign=ci%2fcd%20goat_060422](https://www.cidersecurity.io/blog/research/ppe-poisoned-pipeline-execution/?utm_source=github&utm_medium=github_page&utm_campaign=ci%2fcd%20goat_060422)
103105

104-
{{#include ../banners/hacktricks-training.md}}
105-
106-
107106

107+
{{#include ../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)