Skip to content

feat(authoring) (3/6): MCP probing and the security policies - #7

Open
zjncs wants to merge 2 commits into
feat/authoring-executionfrom
feat/authoring-mcp-security
Open

zjncs wants to merge 2 commits into
feat/authoring-executionfrom
feat/authoring-mcp-security

Conversation

@zjncs

@zjncs zjncs commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Layer (b2) of the authoring platform split (iflytek#934 on iflytek/skillhub), stacking on layer (b1) (#1003). This is the layer for the dedicated security review.

Retargets to upstream main as soon as (b1) merges; the diff is the (b2)-only slice — 29 files, +3.1k.

What this layer adds

Security policies (the dedicated-review surface)

  • Shared AuthoringSecurityPolicy gates OpenAI-compatible and http/sse MCP endpoints at save time and again at connect time: cloud-metadata/link-local/multicast always rejected; loopback/RFC1918/ULA/CGNAT/RFC 2544 behind per-surface allow-private-endpoints flags (default off); unresolvable hosts rejected. Hermetic tests via an injectable resolver.
  • stdio MCP: off by default; in docker execution-mode its command runs inside a hardened container torn down on close; envRefs limited to the operator-configured allowlist (default empty = all rejected).
  • execution-mode defaults to docker; inline fails startup outside local/dev/test (AuthoringStartupGuard).
  • HTTP redirects never followed; response bodies and stdio lines capped at 2 MiB.

MCP probing during validation

Declared servers are connected, initialized and tools/list-ed for real before the behavior layer relies on them; discovered tools surface in the event stream, unknown toolFilters warn without failing.

OpenAI-compatible adapter

Prompt tasks with an MCP tool loop, guarded by the same endpoint policy.

Also repairs an application.yml merge artifact from the previous monolithic branch (authoring runtime keys had been nested under github-sync).

Verification

Security-policy classification per surface, redirect refusal against the metadata range, response/line caps, envRef allowlist filtering, docker-wrapped command construction, MCP handshake against a real local HTTP server, stdio against a subprocess, OpenAI tool loop with MCP execution, and the runtime flow integration test covering the save-time rejections — 48 tests, 0 failures.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 05:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
@zjncs
zjncs force-pushed the feat/authoring-execution branch from 8c6fcbd to 4861213 Compare October 27, 2026 07:01
@zjncs
zjncs force-pushed the feat/authoring-mcp-security branch from 4c8399d to 3e1c5a2 Compare October 27, 2026 07:01
@zjncs zjncs changed the title feat(authoring) (3/5): MCP probing and the security policies feat(authoring) (3/6): MCP probing and the security policies Oct 28, 2026
…cies

Layer (b2) of the authoring platform (iflytek#934), the second half of the split
runtime layer — the surface for the dedicated security review:

- **Shared AuthoringSecurityPolicy** gates OpenAI-compatible and http/sse
  MCP endpoints at save time and again at connect time: cloud-metadata/
  link-local/multicast always rejected; loopback/RFC1918/ULA/CGNAT/
  RFC 2544 behind per-surface allow-private-endpoints flags (default
  off); unresolvable hosts rejected. The policy resolves through an
  injectable resolver so tests stay hermetic.
- **stdio MCP**: off by default; in docker execution-mode its command
  runs inside a hardened container torn down on close; envRefs limited
  to the operator-configured allowlist (default empty = all rejected).
- **MCP probing during validation**: declared servers are connected,
  initialized and tools/list-ed for real before the behavior layer
  relies on them; discovered tools surface in the event stream, unknown
  toolFilters warn without failing.
- **OpenAI-compatible adapter** for prompt tasks with an MCP tool loop,
  guarded by the same endpoint policy; execution-mode defaults to docker
  and inline fails startup outside local/dev/test (AuthoringStartupGuard).
- HTTP redirects never followed; response bodies and stdio lines capped
  at 2 MiB.
- Also repairs an application.yml merge artifact from the previous
  monolithic branch: the authoring runtime keys had been nested under
  github-sync; they now sit under skillhub.authoring where they belong.

Verified: security-policy classification per surface (hermetic DNS),
redirect refusal against the metadata range, response/line caps, envRef
allowlist filtering, docker-wrapped command construction, MCP handshake
against a real local HTTP server, stdio against a python3 subprocess,
OpenAI tool loop with MCP execution (48 tests), and the runtime flow
integration test covering the save-time rejections (cloud-metadata
endpoints, non-allowlisted envRefs, metadata-range LLM endpoints) plus
the MCP-probed three-layer validation.

Signed-off-by: zjncs <18910855655@163.com>
@zjncs
zjncs force-pushed the feat/authoring-mcp-security branch from 3e1c5a2 to 3d295d3 Compare October 28, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants