Skip to content

fix: close CLI proxy alias and interspersed-flag bypasses - #11470

Merged
lpcox merged 2 commits into
mainfrom
lpcox-fix-cli-proxy-command-classification
Nov 11, 2026
Merged

lpcox merged 2 commits into
mainfrom
lpcox-fix-cli-proxy-command-classification

Conversation

@lpcox

@lpcox lpcox commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Classify command paths using the pinned gh CLI's shallow Cobra discovery semantics rather than literal argv adjacency or a generic flag/value guess. Handle separate, equals, and attached flag values, discovery-time booleans, flags before/between command words, and -- termination.
  • Canonicalize built-in/default aliases of policy-controlled commands: co / pr co → pr checkout, cs → codespace, and ext / extensions → extension.
  • Preserve allowed argument vectors, command-like flag values and positional operands, and the separate enclave issues-read-v1 grammar. Document the parser/version contract and image rollout requirement.

Resolves githubnext/gh-aw-security#3383
Resolves githubnext/gh-aw-security#3388

Evidence and validation

Both reports remain reproducible on current main (32541bf3cdccf9ee6490366fcf2b78777df156f0); no existing fix PR was found. Against that baseline, the real HTTP handler dispatched co 42, pr co 42, pr -R owner/repo checkout 42, and pr -Rowner/repo checkout 42 to an inert recording executable (200), while literal pr checkout 42 was rejected (403).

The new regressions assert denied inputs receive 403 without any fixture dispatch and allowed controls reach the fixture with byte-for-byte unchanged argv. Coverage includes alias/flag combinations, every existing denied command path, flag placement, --, command-like values/operands, invalid syntax that never selects a denied leaf, and enclave routing.

  • Full CLI proxy suite: 904 tests passed, with local gh 2.102.1, then again with the sidecar's exact pinned gh 2.98.0 (official release checksum verified).
  • Real-gh parser checks use isolated HOME/config, dummy credentials, loopback-only host selection, and help-only invocations; no checkout, cloning, SSH, real repositories, or upstream requests are executed.
  • npm run lint passed (pre-existing warnings); npm run build and git diff --check passed.

Scope and rollout

The reports' repo -R ... clone / gist -R ... clone variants are rejected by real gh as unsupported flags, unlike the confirmed pr -R ... checkout form. Policy still rejects their discovered denied command paths; this PR does not claim those unsupported variants execute in gh.

The discovery/alias table is deliberately limited to the policy-controlled boundaries and must remain aligned with the Dockerfile's pinned gh version. User aliases are not loaded from an agent-controlled config. No api-proxy/mcpg changes, security-card/pin edits, live workflow dispatches, or deployment changes are included. The repair takes effect only after a rebuilt CLI-proxy image is deployed; existing images remain unchanged.

Match gh's command discovery for interspersed flags and canonicalize built-in aliases
before enforcing shim-bypass and meta-command denials. Preserve accepted argv and the
separate enclave grammar, with policy, HTTP recording-fixture, and real-gh help-only
regressions.

Resolves githubnext/gh-aw-security#3383
Resolves githubnext/gh-aw-security#3388

Co-authored-by: Copilot App <[email protected]>
Copilot AI adaptive review requested due to automatic review settings November 11, 2026 16:08
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-11470 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit 9c8fc3b

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The proxy’s UTF-16 length check diverges from the pinned CLI’s UTF-8 parsing and can miss denied command paths, while contract tests do not ensure they use the pinned CLI version.

2 open issues
What changed in this PR

This PR hardens AWF’s GitHub CLI proxy by updating command classification to address alias and interspersed-flag bypasses while preserving allowed arguments and enclave validation.

Changes:

  • Models Cobra command discovery and canonicalizes policy-controlled aliases.
  • Adds policy, HTTP dispatch, unchanged-argv, and real-gh parser regressions.
  • Documents the pinned-parser contract and image rebuild/deployment requirement.
File Description
docs/​gh-cli-proxy-design.md Documents classification behavior, version alignment, and rollout requirements.
containers/​cli-proxy/​server.test.js Adds discovery, alias, dispatch-boundary, and enclave regressions.
containers/​cli-proxy/​security.js Replaces adjacency-based checks with shallow command discovery and alias normalization.

Review effort: Max (auto)

Comment thread containers/cli-proxy/security.js Resolved
Comment thread containers/cli-proxy/server.test.js Outdated
Comment on lines +239 to +241
const result = spawnSync('gh', [...args, '--help'], {
cwd: directory, env, encoding: 'utf8', timeout: 5000,
});
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite completed successfully!

Build Test Suite

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Build Test Suite · auto (Claude Sonnet 5.5) · ~22 AIC · ⊞ 5.9K · ◷

Generated by Build Test Suite for #11470

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

Smoke Copilot Network Isolation

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Smoke Copilot Network Isolation · auto (Claude Sonnet 5.5) · ~11 AIC · ⊞ 9.8K · ◷

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Claude passed

Generated by Smoke Claude for #11470

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

Smoke Chroot

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Smoke Chroot · auto (Claude Sonnet 5.5) · ~10 AIC · ⊞ 8.2K · ◷

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

Smoke Codex

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Smoke Codex · gpt54 · ~16 AIC · ⊞ 22.5K · ◷

🔮 The oracle has spoken through Smoke Codex

@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Nov 11, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copilot AI commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in e6ef3e5: single-dash discovery now uses UTF-8 byte length, non-ASCII cases are covered, and CI provisions/checks the Dockerfile-pinned gh 2.98.0 for parser-contract tests.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@lpcox Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Claude passed

Generated by Smoke Claude for #11470

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

Smoke OTel Tracing

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Smoke OTel Tracing · auto (Claude Sonnet 5.5) · ~17 AIC · ⊞ 5.5K · ◷

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

Smoke Copilot BYOK

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Smoke Copilot BYOK · haiku45 · ~7 AIC · ⊞ 7.0K · ◷

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Security Guard completed successfully!

Security Guard

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Security Guard · auto (Claude Sonnet 5.5) · ~13 AIC · ⊞ 9.0K · ◷

Generated by Security Guard for #11470

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

Smoke Codex

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Smoke Codex · gpt54 · ~14 AIC · ⊞ 22.5K · ◷

🔮 The oracle has spoken through Smoke Codex

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

Smoke Chroot

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Smoke Chroot · auto (Claude Sonnet 5.5) · ~13 AIC · ⊞ 8.2K · ◷

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite completed successfully!

Build Test Suite

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Build Test Suite · auto (Claude Sonnet 5.5) · ~27 AIC · ⊞ 5.9K · ◷

Generated by Build Test Suite for #11470

@github-actions

Copy link
Copy Markdown
Contributor

EGRESS_RESULT allow=pass deny=pass

  • ✅ Allowed domain (api.github.com → 200)
  • ✅ Blocked domain (example.com blocked)

Overall: PASS — cc @lpcox

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

  • API status: ✅ PASS
  • GitHub check: ✅ PASS
  • File status: ✅ PASS

Overall result: PASS

Generated by Smoke Claude for #11470 · claude · haiku45 · ~36 AIC · ⊞ 6.3K · ◷
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test

  • Use published AWF artifacts for refactoring scanner ✅
  • fix: preserve mounted hosts inode during enclave gateway setup ✅
  • GitHub PR details ✅
  • Playwright title check ❌
  • File write/read ✅
  • Build AWF ✅
  • Overall: FAIL

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia ✅ 1/1 passed ✅ PASS
Bun hono ✅ 1/1 passed ✅ PASS
C++ fmt ✅ N/A ✅ PASS
C++ json ✅ N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world ✅ N/A ✅ PASS
.NET json-parse ✅ N/A ✅ PASS
Go color ✅ ok ✅ PASS
Go env ✅ ok ✅ PASS
Go uuid ✅ ok ✅ PASS
Java gson ❌ 0/? (not run) ❌ FAIL
Java caffeine ❌ 0/? (not run) ❌ FAIL
Node.js clsx ✅ all passed ✅ PASS
Node.js execa ✅ all passed ✅ PASS
Node.js p-limit ✅ all passed ✅ PASS
Rust fd ✅ 1/1 passed ✅ PASS
Rust zoxide ✅ 1/1 passed ✅ PASS

Overall: 7/8 ecosystems passed — FAIL

Java failure details:

  • ~/.m2 is root-owned, so Maven could not create ~/.m2/repository.
  • With a disposable local repo, Maven then failed to resolve maven-resources-plugin:3.4.0 from Maven Central: InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty.
  • Cause: Java truststore is empty or unavailable in the runner. I did not work around it.

Notes:

  • .NET needed XDG_RUNTIME_DIR set to a temp dir because /run/user/1001 is missing.
  • The build-test label was not added because Java failed.

Generated by Build Test Suite for #11470 · copilot · auto (Claude Sonnet 5.5) · ~27 AIC · ⊞ 5.9K · ◷
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode ✅

Test Results:

  • ✅ GitHub MCP connectivity verified
  • ✅ GitHub.com connectivity (HTTP 200)
  • ✅ File write/read test passed
  • ✅ BYOK inference path working (agent → api-proxy → api.githubcopilot.com)

Status: PASS — Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy sidecar

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Cloud Hypervisor + Copilot smoke test

  1. Merged PR lookup: PASS
  2. github.com connectivity: PASS (HTTP 200)
  3. File write/read: PASS
  4. example.com blocked: PASS (HTTP 000)

Overall: PASS

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

OTEL smoke test

  • ✅ S1: otel.js loads; exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, routerCallTracing, shutdown, isEnabled...
  • ✅ S2: OTEL tests 3 suites, 75/75 passed (re-run locally)
  • ✅ S3: env forwarding present (GITHUB_AW_OTEL_TRACE_ID/PARENT_SPAN_ID in env-passthrough.ts; OTEL_EXPORTER_OTLP_* in api-proxy-env-config.ts)
  • ✅ S4: onUsage hook present in token-tracker-http.js
  • ✅ S5: otel.jsonl has 1 line locally (file fallback); I did not verify OTLP export

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Copilot: PR "feat: send each budget notice once to every conversation in the run"

  • GitHub MCP ✅
  • GitHub.com connectivity ✅
  • File write/read ✅

Overall: PASS — @lpcox

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.16 Python 3.12.16 ✅ YES
Node.js v24.22.2 v22.23.2 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Result: Not all tests passed (Node.js version mismatch), so the smoke-chroot label was not added.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke services: ✅ Redis PONG · ✅ pg_isready · ✅ SELECT 1 — PASS

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@lpcox
lpcox merged commit 9950d3c into main Nov 11, 2026
133 of 134 checks passed
@lpcox
lpcox deleted the lpcox-fix-cli-proxy-command-classification branch November 11, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants