Skip to content

Commit c24617d

Browse files
authored
feat(recon): add kubeflow pipelines and metaflow exposure modules (#290)
detect an anonymously reachable kubeflow pipelines apiserver, whose same api accepts pipeline run submission with an attacker-supplied workflow manifest (arbitrary container execution), and a metaflow metadata service leaking flow and owner enumeration. match distinctive snake_case json keys with status 200, fail closed on empty instances to avoid the bare-substring false-positive class.
1 parent b4fae85 commit c24617d

3 files changed

Lines changed: 195 additions & 0 deletions

File tree

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package modules_test
2+
3+
import (
4+
"context"
5+
"net/http"
6+
"net/http/httptest"
7+
"testing"
8+
"time"
9+
10+
"github.com/vmfunc/sif/internal/modules"
11+
)
12+
13+
func runMLPipelineModule(t *testing.T, file string, status int, body string) *modules.Result {
14+
t.Helper()
15+
def, err := modules.ParseYAMLModule(file)
16+
if err != nil {
17+
t.Fatalf("parse %s: %v", file, err)
18+
}
19+
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
20+
w.WriteHeader(status)
21+
_, _ = w.Write([]byte(body))
22+
}))
23+
defer srv.Close()
24+
25+
res, err := modules.ExecuteHTTPModule(context.Background(), srv.URL, def, modules.Options{
26+
Timeout: 5 * time.Second,
27+
Threads: 2,
28+
})
29+
if err != nil {
30+
t.Fatalf("execute %s: %v", file, err)
31+
}
32+
return res
33+
}
34+
35+
func mlPipelineExtract(res *modules.Result, key string) string {
36+
for _, f := range res.Findings {
37+
if v := f.Extracted[key]; v != "" {
38+
return v
39+
}
40+
}
41+
return ""
42+
}
43+
44+
func TestMLPipelineExposureModules(t *testing.T) {
45+
const kubeflow = "../../modules/recon/kubeflow-pipelines-exposure.yaml"
46+
const metaflow = "../../modules/recon/metaflow-metadata-exposure.yaml"
47+
48+
t.Run("a kubeflow pipelines list is flagged with its pipeline count", func(t *testing.T) {
49+
body := `{"pipelines":[{"id":"a1b2c3","created_at":"2026-01-01T00:00:00Z","name":"training-pipeline",` +
50+
`"parameters":[],"resource_references":[]}],"total_size":1,"next_page_token":""}`
51+
res := runMLPipelineModule(t, kubeflow, 200, body)
52+
if len(res.Findings) == 0 {
53+
t.Fatal("expected a kubeflow finding")
54+
}
55+
if v := mlPipelineExtract(res, "kubeflow_pipeline_count"); v != "1" {
56+
t.Errorf("kubeflow_pipeline_count=%q, want 1", v)
57+
}
58+
})
59+
60+
t.Run("a generic pipelines-word page is not flagged as kubeflow", func(t *testing.T) {
61+
// shares the bare word "pipelines" (a CI product's dashboard prose) but not the
62+
// kubeflow pagination shape.
63+
body := `{"message":"see your pipelines dashboard","pipelines_url":"https://ci.example.com/pipelines"}`
64+
if res := runMLPipelineModule(t, kubeflow, 200, body); len(res.Findings) > 0 {
65+
t.Errorf("a page merely mentioning pipelines should not match, got %d findings", len(res.Findings))
66+
}
67+
})
68+
69+
t.Run("a metaflow flows list is flagged with a flow id", func(t *testing.T) {
70+
body := `[{"flow_id":"TrainingFlow","user_name":"data-eng","ts_epoch":1735689600000,` +
71+
`"tags":null,"system_tags":["production"]}]`
72+
res := runMLPipelineModule(t, metaflow, 200, body)
73+
if len(res.Findings) == 0 {
74+
t.Fatal("expected a metaflow finding")
75+
}
76+
if v := mlPipelineExtract(res, "metaflow_flow_id"); v != "TrainingFlow" {
77+
t.Errorf("metaflow_flow_id=%q, want TrainingFlow", v)
78+
}
79+
})
80+
81+
t.Run("a generic user/timestamp array is not flagged as metaflow", func(t *testing.T) {
82+
body := `[{"user_name":"alice","ts_epoch":1735689600000,"role":"admin"}]`
83+
if res := runMLPipelineModule(t, metaflow, 200, body); len(res.Findings) > 0 {
84+
t.Errorf("a body missing flow_id should not match, got %d findings", len(res.Findings))
85+
}
86+
})
87+
88+
t.Run("a plain 200 body is not a leak", func(t *testing.T) {
89+
for _, file := range []string{kubeflow, metaflow} {
90+
if res := runMLPipelineModule(t, file, 200, "ok"); len(res.Findings) > 0 {
91+
t.Errorf("%s: a plain 200 body should not match, got %d findings", file, len(res.Findings))
92+
}
93+
}
94+
})
95+
96+
t.Run("a 401 is not a leak", func(t *testing.T) {
97+
for _, file := range []string{kubeflow, metaflow} {
98+
if res := runMLPipelineModule(t, file, 401, `{"error":"unauthorized"}`); len(res.Findings) > 0 {
99+
t.Errorf("%s: a 401 should not match, got %d findings", file, len(res.Findings))
100+
}
101+
}
102+
})
103+
104+
t.Run("a 404 is not a leak", func(t *testing.T) {
105+
for _, file := range []string{kubeflow, metaflow} {
106+
if res := runMLPipelineModule(t, file, 404, "not found"); len(res.Findings) > 0 {
107+
t.Errorf("%s: a 404 should not match, got %d findings", file, len(res.Findings))
108+
}
109+
}
110+
})
111+
112+
t.Run("a different product's version api is not flagged", func(t *testing.T) {
113+
// argocd's /api/version shape: shares no kubeflow/metaflow anchors.
114+
body := `{"Version":"v2.9.3","KustomizeVersion":"v5.3.0","HelmVersion":"v3.14.0"}`
115+
for _, file := range []string{kubeflow, metaflow} {
116+
if res := runMLPipelineModule(t, file, 200, body); len(res.Findings) > 0 {
117+
t.Errorf("%s: a different product's version body should not match, got %d findings", file, len(res.Findings))
118+
}
119+
}
120+
})
121+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Kubeflow Pipelines API Exposure Detection Module
2+
3+
id: kubeflow-pipelines-exposure
4+
info:
5+
name: Kubeflow Pipelines API Exposure
6+
author: sif
7+
severity: high
8+
description: Detects a Kubeflow Pipelines api server reachable without going through the istio/dex auth proxy, listing registered pipelines over its rest api; the same api accepts pipeline run submission, which executes arbitrary containers on the backing cluster
9+
tags: [kubeflow, mlops, pipelines, kubernetes, data-orchestration, rce, exposure, unauth, recon]
10+
11+
type: http
12+
13+
http:
14+
method: GET
15+
paths:
16+
- "{{BaseURL}}/apis/v1beta1/pipelines"
17+
18+
matchers:
19+
- type: word
20+
part: body
21+
words:
22+
- "\"pipelines\""
23+
- "\"total_size\""
24+
- "\"next_page_token\""
25+
condition: and
26+
27+
- type: status
28+
status:
29+
- 200
30+
31+
extractors:
32+
- type: regex
33+
name: kubeflow_pipeline_count
34+
part: body
35+
regex:
36+
- '"total_size"\s*:\s*([0-9]+)'
37+
group: 1
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Metaflow Metadata Service Exposure Detection Module
2+
3+
id: metaflow-metadata-exposure
4+
info:
5+
name: Metaflow Metadata Service Exposure
6+
author: sif
7+
severity: medium
8+
description: Detects a Metaflow metadata service reachable without auth, disclosing every registered flow's name, owner and creation time over its rest api
9+
tags: [metaflow, mlops, data-orchestration, pipeline, api, exposure, unauth, recon]
10+
11+
type: http
12+
13+
http:
14+
method: GET
15+
paths:
16+
- "{{BaseURL}}/flows"
17+
18+
matchers:
19+
- type: word
20+
part: body
21+
words:
22+
- "\"flow_id\""
23+
- "\"user_name\""
24+
- "\"ts_epoch\""
25+
condition: and
26+
27+
- type: status
28+
status:
29+
- 200
30+
31+
extractors:
32+
- type: regex
33+
name: metaflow_flow_id
34+
part: body
35+
regex:
36+
- '"flow_id"\s*:\s*"([^"]+)"'
37+
group: 1

0 commit comments

Comments
 (0)