Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/agents/diagnose-awf.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ Reuse these instead of duplicating their commands:
| MCP GitHub tool calls fail while provider inference still works | AUTH-003 | auth | workaround |
| Anthropic OIDC initialization fails until the API-proxy token retry | AUTH-004 | auth | fixed |
| Agent exhausts early 503 retries while the API proxy has no token | AUTH-004 | auth | fixed |
| Client receives 502 with error "Upstream response could not be safely inspected" | AUTH-005 | auth | workaround |
| Client message "Unsupported upstream response content encoding" | AUTH-005 | auth | workaround |
| Upstream response is aborted mid-stream with a request_error log event while the provider is healthy | AUTH-005 | auth | workaround |
| safe output validation failed in the workflow run | CI-001 | ci | workaround |
| The agent job succeeds but the safe-output collection step exits non-zero | CI-001 | ci | workaround |
| create-pull-request rejected: file not in allowed-files | CI-001 | ci | workaround |
Expand Down Expand Up @@ -424,6 +427,20 @@ Reuse these instead of duplicating their commands:
- **Provenance:** pull-request: https://github.com/github/gh-aw-firewall/pull/10495 · code: src/services/api-proxy-service-config.ts · test: src/services/api-proxy-service-config.test.ts · test: src/compose-generator.test.ts · doc: docs/auth-matrix.md
- **Owner:** @github/gh-aw-firewall-maintainers · **Review by:** 2026-12-09

### AUTH-005 — API-proxy refuses an upstream response it cannot safely inspect for credential echoes

- **Boundary:** auth · **Status:** workaround
- **Affects:** runner=any, runtime=any, provider=any, auth=any
- **Versions:** introduced=unknown, fixed=unknown
- **Symptoms:** Client receives 502 with error "Upstream response could not be safely inspected" · Client message "Unsupported upstream response content encoding" · Upstream response is aborted mid-stream with a request_error log event while the provider is healthy
- **Discriminating conditions:** The API proxy injected a credential into the request, so response masking is active · A body-bearing upstream response has a Content-Encoding other than identity, gzip, deflate or br, or a corrupt or truncated compressed body · This is a response-inspection failure, not a provider 401/403; do not rotate keys or change auth mode for it
- **Root cause:** The API proxy masks any injected credential value an upstream echoes in response bodies, headers or errors. It must decode body-bearing compressed responses to do so, and it fails closed with 502 rather than forwarding bytes it cannot inspect. An unsupported encoding or a damaged compressed body therefore surfaces as a proxy error even though the provider authenticated the request. Bodyless responses are not decoded or encoding-validated.
- **Safe probe:** `docker logs awf-api-proxy 2>&1 | grep -E 'request_error|Unsupported upstream response content encoding'` → Run while the containers are kept (--keep-containers). Matches show request_error events with credential-masked error text; compare the matched request's provider and path with the failing call. Do not print request headers, docker inspect output or the container environment.
- **Action:** Retry the request; a truncated or corrupt compressed body is usually transient. For a persistent unsupported encoding on a body-bearing response, have the client send Accept-Encoding limited to identity, gzip, deflate or br (the proxy already narrows the header for most requests) or report the provider and endpoint. Never disable masking, expose provider keys to the agent, or treat the 502 as an authentication failure. A shipped release containing this behavior is not verified here.
- **Related:** AUTH-002
- **Provenance:** pull-request: https://github.com/github/gh-aw-firewall/pull/11471 · code: containers/api-proxy/credential-protection.js · code: containers/api-proxy/upstream-http.js · test: containers/api-proxy/server.credential-isolation.test.js · test: containers/api-proxy/credential-protection.test.js · doc: Upstream credential-echo masking (docs/api-proxy-sidecar.md)
- **Owner:** @github/gh-aw-firewall-maintainers · **Review by:** 2027-03-31

## Boundary: ci

### CI-001 — gh-aw safe-output step fails because the emitted payload violates the declared contract
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/shared/diagnosis-findings.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Match the narrowest finding ID. When nothing matches, say so and request the sma
| MCP GitHub tool calls fail while provider inference still works | AUTH-003 | auth | workaround |
| Anthropic OIDC initialization fails until the API-proxy token retry | AUTH-004 | auth | fixed |
| Agent exhausts early 503 retries while the API proxy has no token | AUTH-004 | auth | fixed |
| Client receives 502 with error "Upstream response could not be safely inspected" | AUTH-005 | auth | workaround |
| Client message "Unsupported upstream response content encoding" | AUTH-005 | auth | workaround |
| Upstream response is aborted mid-stream with a request_error log event while the provider is healthy | AUTH-005 | auth | workaround |
| safe output validation failed in the workflow run | CI-001 | ci | workaround |
| The agent job succeeds but the safe-output collection step exits non-zero | CI-001 | ci | workaround |
| create-pull-request rejected: file not in allowed-files | CI-001 | ci | workaround |
Expand Down Expand Up @@ -355,6 +358,20 @@ Match the narrowest finding ID. When nothing matches, say so and request the sma
- **Provenance:** pull-request: https://github.com/github/gh-aw-firewall/pull/10495 · code: src/services/api-proxy-service-config.ts · test: src/services/api-proxy-service-config.test.ts · test: src/compose-generator.test.ts · doc: docs/auth-matrix.md
- **Owner:** @github/gh-aw-firewall-maintainers · **Review by:** 2026-12-09

### AUTH-005 — API-proxy refuses an upstream response it cannot safely inspect for credential echoes

- **Boundary:** auth · **Status:** workaround
- **Affects:** runner=any, runtime=any, provider=any, auth=any
- **Versions:** introduced=unknown, fixed=unknown
- **Symptoms:** Client receives 502 with error "Upstream response could not be safely inspected" · Client message "Unsupported upstream response content encoding" · Upstream response is aborted mid-stream with a request_error log event while the provider is healthy
- **Discriminating conditions:** The API proxy injected a credential into the request, so response masking is active · A body-bearing upstream response has a Content-Encoding other than identity, gzip, deflate or br, or a corrupt or truncated compressed body · This is a response-inspection failure, not a provider 401/403; do not rotate keys or change auth mode for it
- **Root cause:** The API proxy masks any injected credential value an upstream echoes in response bodies, headers or errors. It must decode body-bearing compressed responses to do so, and it fails closed with 502 rather than forwarding bytes it cannot inspect. An unsupported encoding or a damaged compressed body therefore surfaces as a proxy error even though the provider authenticated the request. Bodyless responses are not decoded or encoding-validated.
- **Safe probe:** `docker logs awf-api-proxy 2>&1 | grep -E 'request_error|Unsupported upstream response content encoding'` → Run while the containers are kept (--keep-containers). Matches show request_error events with credential-masked error text; compare the matched request's provider and path with the failing call. Do not print request headers, docker inspect output or the container environment.
- **Action:** Retry the request; a truncated or corrupt compressed body is usually transient. For a persistent unsupported encoding on a body-bearing response, have the client send Accept-Encoding limited to identity, gzip, deflate or br (the proxy already narrows the header for most requests) or report the provider and endpoint. Never disable masking, expose provider keys to the agent, or treat the 502 as an authentication failure. A shipped release containing this behavior is not verified here.
- **Related:** AUTH-002
- **Provenance:** pull-request: https://github.com/github/gh-aw-firewall/pull/11471 · code: containers/api-proxy/credential-protection.js · code: containers/api-proxy/upstream-http.js · test: containers/api-proxy/server.credential-isolation.test.js · test: containers/api-proxy/credential-protection.test.js · doc: Upstream credential-echo masking (docs/api-proxy-sidecar.md)
- **Owner:** @github/gh-aw-firewall-maintainers · **Review by:** 2027-03-31

## Boundary: ci

### CI-001 — gh-aw safe-output step fails because the emitted payload violates the declared contract
Expand Down
15 changes: 15 additions & 0 deletions docs/api-proxy-sidecar.md
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,21 @@ API keys are held in the sidecar container, not the agent:
- A compromised agent cannot exfiltrate credentials
- Keys are not exposed in the agent container's stdout/stderr logs

#### Upstream credential-echo masking

The sidecar also protects against an upstream that echoes the credential it was just given (for example in a `401`/`502` diagnostic body, a response header, or a transport error). For each request it remembers the credential values it actually injected: provider API keys, bearer tokens, the freshly minted OIDC token, trusted-service secret headers, and the AWS access key, session token and signature of a SigV4-signed request. It masks those values before anything reaches the agent or the sidecar log:

- **Response bodies** are masked in a stream, holding back only a suffix that could complete a credential in the next chunk. For identity-encoded bodies, masking is same-byte-length (a byte that does not occur in any credential), so an existing `Content-Length` remains valid. JSON-escaped forms are masked as well.
- **Response headers** whose name or value contain a credential are dropped or masked, and integrity headers (`ETag`, `Content-MD5`, `Digest`, `Content-Digest`, `Repr-Digest`) are removed from masked responses because they describe the original bytes.
- **Body-bearing compressed responses** (`gzip`, `deflate`, `br`) are decoded, masked and re-encoded. Since the encoded body can change size, `Content-Length` is removed. An unsupported `Content-Encoding`, or a corrupt or truncated compressed body, fails closed: the client receives `502` `Upstream response could not be safely inspected` (or the connection is aborted) instead of unmasked bytes.
- **Errors and logs** (`request_error`, WebSocket upgrade failures) pass through the same redaction, and WebSocket handshakes, message frames and close reasons are masked without buffering ordinary model output.

Encoding validation applies only when a response body is present. `HEAD`, `204`, `205`, `304`, and responses with `Content-Length: 0` are treated as bodyless: their `Content-Encoding` is not decoded or validated and can be retained, including an unsupported value.

Masking is a defense-in-depth layer for credentials the sidecar itself injected; it does not replace keeping keys out of the agent environment. A `502` with `Upstream response could not be safely inspected` is a masking failure, not a provider authentication error.

Implementation: `containers/api-proxy/credential-protection.js`, `containers/api-proxy/credential-websocket.js`. Tests: `containers/api-proxy/credential-protection.test.js`, `containers/api-proxy/server.credential-isolation.test.js`.

:::danger[Protect host credentials]
API keys are stored in the sidecar container's environment and in the Docker Compose configuration on disk. Protect the host filesystem and configuration accordingly. Only non-sensitive key prefixes are logged for debugging.
:::
Expand Down
1 change: 1 addition & 0 deletions docs/authentication-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ This prevents tokens from being visible in `/proc/1/environ` after the agent sta
- API keys are not visible in `/proc/self/environ` or `/proc/*/environ`
- Compromised agent code cannot exfiltrate API keys (they don't exist)
- Only the api-proxy container has access to API keys
- If an upstream echoes an injected credential back (response body, headers, or error text), the api-proxy masks it before it reaches the agent or the logs; see [Upstream credential-echo masking](./api-proxy-sidecar.md#upstream-credential-echo-masking)

### Network isolation

Expand Down
4 changes: 4 additions & 0 deletions docs/diagnostics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ npm run diagnostics:freshness -- --as-of 2026-11-09 # reproducible UTC deadline
| AUTH-002 | auth | API-proxy OIDC mode is configured but the Actions token request variables are missing | workaround | [`findings/auth/AUTH-002.json`](./findings/auth/AUTH-002.json) |
| AUTH-003 | auth | gh-aw-launched HTTP MCP GitHub server fails the OIDC boundary check | workaround | [`findings/auth/AUTH-003.json`](./findings/auth/AUTH-003.json) |
| AUTH-004 | auth | Primary API-proxy OIDC initialization races Squid readiness | fixed | [`findings/auth/AUTH-004.json`](./findings/auth/AUTH-004.json) |
| AUTH-005 | auth | API-proxy refuses an upstream response it cannot safely inspect for credential echoes | workaround | [`findings/auth/AUTH-005.json`](./findings/auth/AUTH-005.json) |
| CI-001 | ci | gh-aw safe-output step fails because the emitted payload violates the declared contract | workaround | [`findings/ci/CI-001.json`](./findings/ci/CI-001.json) |
| CI-002 | ci | Compiler-owned enclave gateway is unavailable or violates the handoff contract | workaround | [`findings/ci/CI-002.json`](./findings/ci/CI-002.json) |
| CI-003 | ci | Cloud Hypervisor regression admission rejects a regional Actions OIDC endpoint | fixed | [`findings/ci/CI-003.json`](./findings/ci/CI-003.json) |
Expand Down Expand Up @@ -332,6 +333,9 @@ npm run diagnostics:freshness -- --as-of 2026-11-09 # reproducible UTC deadline
| MCP GitHub tool calls fail while provider inference still works | AUTH-003 | auth | workaround |
| Anthropic OIDC initialization fails until the API-proxy token retry | AUTH-004 | auth | fixed |
| Agent exhausts early 503 retries while the API proxy has no token | AUTH-004 | auth | fixed |
| Client receives 502 with error "Upstream response could not be safely inspected" | AUTH-005 | auth | workaround |
| Client message "Unsupported upstream response content encoding" | AUTH-005 | auth | workaround |
| Upstream response is aborted mid-stream with a request_error log event while the provider is healthy | AUTH-005 | auth | workaround |
| safe output validation failed in the workflow run | CI-001 | ci | workaround |
| The agent job succeeds but the safe-output collection step exits non-zero | CI-001 | ci | workaround |
| create-pull-request rejected: file not in allowed-files | CI-001 | ci | workaround |
Expand Down
38 changes: 38 additions & 0 deletions docs/diagnostics/findings/auth/AUTH-005.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "../../schema.json",
"id": "AUTH-005",
"boundary": "auth",
"title": "API-proxy refuses an upstream response it cannot safely inspect for credential echoes",
"symptoms": [
"Client receives 502 with error \"Upstream response could not be safely inspected\"",
"Client message \"Unsupported upstream response content encoding\"",
"Upstream response is aborted mid-stream with a request_error log event while the provider is healthy"
],
"conditions": [
"The API proxy injected a credential into the request, so response masking is active",
"A body-bearing upstream response has a Content-Encoding other than identity, gzip, deflate or br, or a corrupt or truncated compressed body",
"This is a response-inspection failure, not a provider 401/403; do not rotate keys or change auth mode for it"
],
"affects": { "runner": "any", "runtime": "any", "provider": "any", "authMode": "any" },
"versions": { "introduced": "unknown", "fixed": "unknown" },
"status": "workaround",
"rootCause": "The API proxy masks any injected credential value an upstream echoes in response bodies, headers or errors. It must decode body-bearing compressed responses to do so, and it fails closed with 502 rather than forwarding bytes it cannot inspect. An unsupported encoding or a damaged compressed body therefore surfaces as a proxy error even though the provider authenticated the request. Bodyless responses are not decoded or encoding-validated.",
"probe": {
"command": "docker logs awf-api-proxy 2>&1 | grep -E 'request_error|Unsupported upstream response content encoding'",
"expect": "Run while the containers are kept (--keep-containers). Matches show request_error events with credential-masked error text; compare the matched request's provider and path with the failing call. Do not print request headers, docker inspect output or the container environment.",
"readOnly": true,
"secretSafe": true
},
"action": "Retry the request; a truncated or corrupt compressed body is usually transient. For a persistent unsupported encoding on a body-bearing response, have the client send Accept-Encoding limited to identity, gzip, deflate or br (the proxy already narrows the header for most requests) or report the provider and endpoint. Never disable masking, expose provider keys to the agent, or treat the 502 as an authentication failure. A shipped release containing this behavior is not verified here.",
"references": [
{ "kind": "pull-request", "ref": "https://github.com/github/gh-aw-firewall/pull/11471" },
{ "kind": "code", "ref": "containers/api-proxy/credential-protection.js" },
{ "kind": "code", "ref": "containers/api-proxy/upstream-http.js" },
{ "kind": "test", "ref": "containers/api-proxy/server.credential-isolation.test.js" },
{ "kind": "test", "ref": "containers/api-proxy/credential-protection.test.js" },
{ "kind": "doc", "ref": "docs/api-proxy-sidecar.md", "title": "Upstream credential-echo masking" }
],
"related": ["AUTH-002"],
"owner": "@github/gh-aw-firewall-maintainers",
"reviewBy": "2027-03-31"
}
Loading