Skip to content

test: verify MCP upload resource limits for alert 1038 - #73821

Merged
pelikhan merged 1 commit into
mainfrom
pelikhan/fix-alert-1038
Nov 1, 2026
Merged

pelikhan merged 1 commit into
mainfrom
pelikhan/fix-alert-1038

Conversation

@pelikhan

@pelikhan pelikhan commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Why

Prevent regressions in the MCP HTTP upload protections associated with security alert 1038. The production fix already landed in #73580, and the live alert was confirmed fixed on November 1, 2026. This PR adds tests only, not a duplicate production fix.

Changes

  • Verify exactly 1,048,576 bytes are accepted for both fixed-length and chunked JSON uploads.
  • Verify an unfinished chunked upload one byte above the limit receives HTTP 413 and its socket closes without waiting for the upload to end.
  • Verify data arriving at 10 seconds, 20 seconds, and 29.999 seconds cannot extend the absolute 30-second upload deadline: HTTP 408 closes the socket, clears the timer, and does not invoke the transport.
  • Confirm legitimate requests still succeed after rejected uploads.

The tests use real HTTP/TCP connections and fake timers for the exact deadline. Authentication behavior and the production runner are unchanged.

Validation

  • Four focused MCP runner, HTTP server, and transport suites: 71 tests passed.
  • make fmt-cjs and make lint-cjs passed, with existing lint warnings only.
  • make agent-report-progress passed, including the 30-test impacted runner suite.

Confirm exact 1 MiB fixed-length and chunked boundaries, immediate socket closure for oversized unfinished uploads, and the absolute 30-second deadline despite continued data. The production fix is already on main and the live alert is fixed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review November 1, 2026 16:02
Copilot AI dynamic review requested due to automatic review settings November 1, 2026 16:02
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

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 Design Decision Gate 🏗️ · routed: gpt56 max · ~1 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

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 Ponytail Reviewer · gpt56 · ~10 AIC · ⌖ ~6 AIC · ⊞ 15.1K · ◷

Generated by Ponytail Reviewer for #73821

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

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 Test Quality Sentinel · haiku45 · ~27 AIC · ⌖ ~9 AIC · ◇ ~3 AIC · ⊞ 9.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions github-actions Bot 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.

Review: no blocking findings

The added coverage is focused and validates the byte-limit and absolute-timeout behavior without changing production code. I found no actionable correctness, security, or maintainability issue on the changed lines. Static review only; tests were not run in this review.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.7K
Comment /review to run again

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.

🟢 Approval recommended

There are no active review issues for the regression-test additions covering MCP HTTP upload limits.

No open issues 🎉

What changed in this PR

Adds regression tests for the MCP HTTP upload limits introduced in #73580, protecting against recurrence of security alert 1038. Production code and authentication behavior remain unchanged.

Changes:

  • Verify fixed-length and chunked JSON uploads succeed at exactly 1 MiB.
  • Verify unfinished uploads exceeding the limit receive HTTP 413 and close promptly.
  • Verify trickled data cannot extend the absolute 30-second deadline, timers are cleared, and valid requests still succeed after rejection.
File Description
actions/​setup/​js/​mcp_http_server_runner.test.cjs Extends upload boundary, socket closure, deadline, and post-rejection recovery coverage.

Review effort: Balanced (auto)

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

✅ Test Quality Score: 97/100 — Excellent

Analyzed 10 test(s): 10 design, 0 implementation, 0 violation(s).

📊 Metrics (10 tests)
Metric Value
Analyzed 10 (Go: 0, JS: 10)
✅ Design 10 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 9 (90%)
Duplicate clusters 0
Inflation NO (0.65:1 ratio)
🚨 Violations 0
Test File Classification Quality
rejects an oversized Content-Length without waiting for the body mcp_http_server_runner.test.cjs:275 design_test, high_value ✅ Boundary enforcement
rejects malformed Content-Length (table-driven, 3 variants) mcp_http_server_runner.test.cjs:284 design_test, high_value ✅ Input validation
accepts a JSON body at the exact byte limit (table-driven, 2 variants) mcp_http_server_runner.test.cjs:293 design_test, high_value ✅ Boundary acceptance
bounds actual chunked bytes, including multi-byte characters mcp_http_server_runner.test.cjs:308 design_test, high_value ✅ UTF-8 edge case
closes a chunked upload one byte above the limit mcp_http_server_runner.test.cjs:320 design_test, high_value ✅ Socket closure
closes a continuously trickled upload at the absolute 30-second deadline mcp_http_server_runner.test.cjs:339 design_test, high_value ✅ Timeout enforcement
expires an incomplete upload mcp_http_server_runner.test.cjs:382 design_test, high_value ✅ Basic timeout
clears the upload deadline before a long-running tool executes mcp_http_server_runner.test.cjs:395 design_test, high_value ✅ Deadline lifecycle
handles an aborted upload and remains available for subsequent requests mcp_http_server_runner.test.cjs:423 design_test, high_value ✅ Error recovery
closes unauthenticated incomplete headers at the header timeout mcp_http_server_runner.test.cjs:443 design_test, high_value ✅ Security/robustness

Verdict

✅ Passed. 0% implementation tests (threshold: 30%). All tests verify behavioral contracts for MCP upload resource limits under alert 1038. Excellent coverage of boundary conditions, timeouts, socket management, and error recovery. No violations detected.

🧪 Test quality analysis by Test Quality Sentinel · copilot · haiku45 · ~27 AIC · ⌖ ~9 AIC · ⊞ 9.2K · ◷
Comment /review to run again

@github-actions github-actions Bot 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.

✅ Test Quality Sentinel: 97/100. 0% implementation tests (threshold: 30%). All 10 tests verify behavioral contracts for MCP upload resource limits with excellent edge-case coverage. No violations detected.

🧪 Test quality analysis by Test Quality Sentinel · copilot · haiku45 · ~27 AIC · ⌖ ~9 AIC · ⊞ 9.2K
Comment /review to run again

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Applied /tdd — this is a clean, test-only PR with no actionable blockers. Approving.

📋 Key Themes & Highlights

Key Themes

  • Single-file, tests-only change (65 additions / 2 deletions) adding regression coverage for security alert 1038, which already has its production fix in #73580.
  • Tests exercise exact boundary conditions: 1,048,576-byte limit (both fixed-length and chunked), rejection one byte above the limit with immediate socket close (413), and the absolute (non-sliding) 30-second upload deadline enforced via fake timers across three trickled writes (408).
  • Each new test confirms the server recovers and accepts a legitimate follow-up request afterward, a good signal that state isn't left corrupted by the rejection path.
  • Test names read as clear specifications (it.each with descriptive chunked/not-chunked variants, explicit deadline semantics in the title) — solid /tdd naming discipline.

Positive Highlights

  • ✅ Asserts the production constants directly (MAX_REQUEST_BODY_BYTES, REQUEST_BODY_TIMEOUT_MS) so the tests fail loudly if the limits are ever changed without updating expectations.
  • ✅ Uses real TCP sockets with fake timers to deterministically test the exact deadline boundary (10s + 10s + 9.999s + 1ms = 30,000ms) instead of relying on flaky wall-clock sleeps.
  • ✅ Verifies socket destruction, timer cleanup (vi.getTimerCount reaches 0), and logger invocation — covers the full observable contract of the timeout path, not just the status code.

Minor, non-blocking note

  • Left one inline suggestion about optionally extracting a small writeChunk helper if more raw chunked-encoding tests get added later, purely for readability — does not affect correctness or block merge.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · ~47 AIC · ⌖ ~16 AIC · ⊞ 10.7K
Comment /matt to run again

expect((await request(currentServer, { method: "POST", path: "/", body: "{}" })).statusCode).toBe(200);
});

it("closes a continuously trickled upload at the absolute 30-second deadline", async () => {

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.

[/codebase-design] Nice regression test for the absolute (non-sliding) 30s deadline — this is exactly the kind of edge case that prevents silent regressions on alert 1038. Minor, non-blocking: the raw-socket + manual chunked-encoding setup (socket.write(\"1\\r\\n (r/redacted)\\n\")) duplicates low-level framing logic that could be extracted into a small writeChunk(socket, data) helper if more timing-sensitive chunked tests get added later, keeping the test body focused on timing assertions rather than wire-format details.

@copilot please address this.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.0

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.

2 participants