Skip to content

Commit 19ad536

Browse files
authored
W-1: Detect direct API bypass in integrity audit + add reusable MCP routing constraint (#3134)
The 2026-04-03 integrity audit flagged the AI Moderator workflow making 3 direct network calls to `api.github.com`, `github.com`, and `chatgpt.com`, bypassing the MCP Gateway entirely — breaking DIFC enforcement and making data access unauditable. ## `integrity-filtering-audit.md` - **Background**: adds "direct API bypass attempts" as an explicit problem category (firewall blocks = signal) - **Step 3.6**: new detection step with targeted bash patterns to surface bypass attempts from logs: ```bash grep -iE 'api\.github\.com|chatgpt\.com|openai\.com|curl.*https?://[^ ]*github|fetch.*https?://[^ ]*github' \ "$TMPDIR"/*/mcp-logs/*.log 2>/dev/null | head -30 ``` - **Step 4**: extends W-1 Warning classification to cover direct API bypass with likely causes (`difc-proxy: true` missing, weak prompt, misconfigured `network.allowed`) and fix pointer - **Issue template**: Runs Analyzed table gains "Agent Invoked" + "Firewall Blocks" columns (matching the actual report format); Recommendations section now requires bypass investigation checklist - **Front matter**: imports `shared/mcp-api-routing.md` so the audit agent itself is subject to the same constraint ## `shared/mcp-api-routing.md` (new) Reusable prompt constraint importable by any workflow (`imports: - shared/mcp-api-routing.md`). Covers: - Hard prohibition on `curl`/`gh api`/`fetch` to `api.github.com` or external AI services - ✅/❌ usage examples - Why bypassing breaks DIFC (no integrity labels → no scope enforcement) - Pre-call checklist (MCP tool, allowed-repos, difc-proxy, no external AI)
2 parents f497a1e + b0aa074 commit 19ad536

2 files changed

Lines changed: 103 additions & 6 deletions

File tree

.github/workflows/integrity-filtering-audit.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ safe-outputs:
3939
timeout-minutes: 20
4040
features:
4141
difc-proxy: true
42+
imports:
43+
- shared/mcp-api-routing.md
4244
---
4345

4446
# Integrity Filtering Audit
@@ -60,6 +62,9 @@ Common problems to look for:
6062
- **Unscoped integrity tags** (e.g., `approved` instead of `approved:owner/repo`)
6163
- **Empty responses** where data was expected (over-filtering)
6264
- **Search result leaks** where out-of-scope items appear in filtered results
65+
- **Direct API bypass attempts** where an agent contacts `api.github.com`, `github.com`,
66+
or external AI services (e.g., `chatgpt.com`, `openai.com`) without going through
67+
the MCP Gateway — these show up as network firewall blocks in the job logs
6368

6469
## Procedure
6570

@@ -110,6 +115,17 @@ For each downloaded artifact set, check:
110115
5. **Scope violations**: Check if any response contains data from repositories
111116
NOT in the workflow's `allowed-repos` policy.
112117

118+
6. **Direct API bypass attempts**: Search job logs and stderr for network firewall
119+
blocks that reveal the agent trying to reach external domains directly instead
120+
of through the MCP Gateway. Key domains to flag:
121+
- `api.github.com` — GitHub API (must go through MCP Gateway, not curl/fetch)
122+
- `github.com` — GitHub web (should not be contacted directly)
123+
- `chatgpt.com`, `openai.com`, `api.openai.com` — external AI services
124+
- Any other non-allowlisted HTTP endpoint
125+
126+
For each block, record: the blocked domain, the number of block events, which
127+
workflow run, and what step appears to have triggered it.
128+
113129
```bash
114130
# Example: Count DIFC events in JSONL
115131
grep -c 'difc_integrity' "$TMPDIR"/*/mcp-logs/rpc-messages.jsonl 2>/dev/null || echo "0"
@@ -119,6 +135,16 @@ grep -iE 'error|failed|blocked|unknown|wasm error:|WASM guard trap' "$TMPDIR"/*/
119135

120136
# Example: Specifically search for WASM guard panics
121137
grep -iE 'wasm error:|WASM guard trap|unreachable' "$TMPDIR"/*/mcp-logs/mcp-gateway.log 2>/dev/null
138+
139+
# Example: Detect direct API bypass attempts in job logs
140+
# The network firewall logs blocked connections; search agent stderr/stdout for clues
141+
grep -iE 'api\.github\.com|chatgpt\.com|openai\.com|curl.*https?://[^ ]*github|fetch.*https?://[^ ]*github' \
142+
"$TMPDIR"/*/mcp-logs/*.log 2>/dev/null | head -30
143+
144+
# Example: Summarize firewall blocks by domain from network-firewall logs (if present)
145+
grep -iE 'BLOCK|DENY|firewall' "$TMPDIR"/*/mcp-logs/*.log 2>/dev/null \
146+
| grep -oE '(api\.github\.com|github\.com|chatgpt\.com|openai\.com|[a-z0-9.-]+\.[a-z]{2,})' \
147+
| sort | uniq -c | sort -rn | head -20
122148
```
123149

124150
### Step 4: Classify Findings
@@ -127,9 +153,20 @@ Classify each finding by severity:
127153
- 🔴 **Critical**: Data leak (out-of-scope data returned), guard bypass, or
128154
labeling failure that could expose unauthorized data
129155
- 🟡 **Warning**: Over-filtering (legitimate data blocked), unscoped tags,
130-
zero DIFC events in a run that should have filtering, or WASM guard trap
156+
zero DIFC events in a run that should have filtering, WASM guard trap, or
157+
**direct API bypass attempt** (agent contacted `api.github.com`, `github.com`,
158+
or an external AI service such as `chatgpt.com` / `openai.com` directly instead
159+
of routing through the MCP Gateway — visible as network firewall blocks)
131160
- 🟢 **Info**: Normal filtering behavior, expected blocks, or configuration notes
132161

162+
When classifying a **direct API bypass** warning (W-1), record:
163+
- The blocked domain(s) and block count
164+
- The workflow name and run ID
165+
- The likely cause: misconfigured `network.allowed` list, agent prompt not
166+
restricting tool use, or the workflow missing `features.difc-proxy: true`
167+
- Recommended fix: strengthen agent system prompt to use MCP Gateway tools
168+
exclusively; see `shared/mcp-api-routing.md` for reusable constraint language
169+
133170
### Step 5: Create Summary Issue
134171

135172
Create an issue with the audit results using the following structure:
@@ -159,7 +196,8 @@ Create an issue with the audit results using the following structure:
159196
<details>
160197
<summary><b>Warnings</b></summary>
161198

162-
[Details of each warning]
199+
[Details of each warning — for direct API bypass (W-1) warnings include: blocked
200+
domain(s), block count, workflow name, likely cause, and recommended fix]
163201

164202
</details>
165203

@@ -172,13 +210,17 @@ Create an issue with the audit results using the following structure:
172210

173211
### Runs Analyzed
174212

175-
| Run | Workflow | Branch | DIFC Events | Filtered | Status |
176-
|-----|----------|--------|-------------|----------|--------|
177-
| [§ID](run_url) | name | branch | N | N | ✅/⚠️/❌ |
213+
| Run | Workflow | Branch | Agent Invoked | DIFC Events | Firewall Blocks | Status |
214+
|-----|----------|--------|---------------|-------------|-----------------|--------|
215+
| [§ID](run_url) | name | branch | ✅/❌ early-exit | N | N/total | ✅/⚠️/❌ |
178216

179217
### Recommendations
180218

181-
[Actionable suggestions based on findings]
219+
[Actionable suggestions based on findings. For direct API bypass (W-1) findings,
220+
always include: 1) which workflow to investigate, 2) whether it has
221+
`features.difc-proxy: true`, 3) whether the agent prompt restricts tool use to
222+
MCP Gateway tools, and 4) a pointer to `shared/mcp-api-routing.md` for reusable
223+
constraint language to add to the workflow prompt.]
182224
```
183225

184226
If there are no findings (all runs look healthy), still create the issue with
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
# MCP Gateway API routing constraints — import this in any workflow that makes
3+
# GitHub API calls to ensure the agent is reminded to use MCP tools exclusively.
4+
---
5+
6+
## ⚠️ IMPORTANT: GitHub API Routing Constraint
7+
8+
**All GitHub API calls MUST be made exclusively through the MCP Gateway's GitHub
9+
MCP server tools.** Direct network access to `api.github.com`, `github.com`, or
10+
any external service is not permitted and will be blocked by the network firewall.
11+
12+
### Correct Usage
13+
14+
Use the provided MCP tools (e.g., `github-mcp-server` toolset) for all GitHub
15+
operations:
16+
17+
```
18+
✅ Use github-mcp-server list_issues with owner=..., repo=...
19+
✅ Use github-mcp-server get_file_contents with owner=..., repo=..., path=...
20+
✅ Use github-mcp-server list_workflow_runs with owner=..., repo=...
21+
```
22+
23+
### Incorrect Usage
24+
25+
Do NOT use `curl`, `wget`, `fetch`, or any other HTTP client to contact GitHub's
26+
APIs directly. Do NOT attempt to contact external AI services:
27+
28+
```
29+
❌ curl https://api.github.com/repos/... (blocked — use MCP tools)
30+
❌ gh api /repos/... (blocked — use MCP tools)
31+
❌ fetch("https://api.github.com/...") (blocked — use MCP tools)
32+
❌ curl https://chatgpt.com/... (blocked — external service)
33+
❌ curl https://api.openai.com/... (blocked — external service)
34+
```
35+
36+
### Why This Matters
37+
38+
- The MCP Gateway applies **DIFC (Decentralized Information Flow Control)**
39+
integrity and secrecy labels to all GitHub API responses, enforcing scope
40+
restrictions and preventing data leaks.
41+
- Direct API calls bypass DIFC enforcement entirely, making it impossible to
42+
audit what data the agent accessed or ensure scope compliance.
43+
- Direct calls to external AI services (e.g., ChatGPT) are out-of-scope and
44+
constitute a security boundary violation; all reasoning must happen inside
45+
the Copilot engine provided by the workflow runtime.
46+
- Network firewall blocks from bypass attempts are **audited** by the Integrity
47+
Filtering Audit workflow and will be flagged as W-1 warnings.
48+
49+
### Checklist
50+
51+
Before making any API call, verify:
52+
1. ✅ Am I using a GitHub MCP server tool (not `curl`, `gh`, or HTTP fetch)?
53+
2. ✅ Is the target repository in the workflow's `allowed-repos` list?
54+
3. ✅ Is `features.difc-proxy: true` enabled in this workflow's configuration?
55+
4. ✅ Am I NOT trying to contact any external AI service API?

0 commit comments

Comments
 (0)