Skip to content

fix: proxy direct APNs HTTP2 sessions#74905

Merged
clawsweeper[bot] merged 25 commits into
mainfrom
apns-http2-proxy-pr
May 4, 2026
Merged

fix: proxy direct APNs HTTP2 sessions#74905
clawsweeper[bot] merged 25 commits into
mainfrom
apns-http2-proxy-pr

Conversation

@jesse-merhi

@jesse-merhi jesse-merhi commented Apr 30, 2026

Copy link
Copy Markdown
Member

Summary

  • route direct APNs HTTP/2 sessions through the active OpenClaw managed proxy using an explicit CONNECT tunnel
  • keep the existing APNs send API; replace only the low-level http2.connect() seam
  • add APNs authority allowlisting, proxy auth handling, credential redaction, bounded CONNECT response parsing, TLS secureConnect/ALPN validation, and regression tests
  • add local lint + OpenGrep guardrails so new production HTTP/2 code uses the wrapper instead of raw http2.connect()
  • track one active managed proxy URL with handle-count lifecycle safety and reject conflicting proxy URL activation

Test Plan

  • OPENCLAW_LOCAL_CHECK=0 pnpm test src/infra/net/http-connect-tunnel.test.ts src/infra/push-apns-http2.test.ts src/infra/push-apns.test.ts src/infra/net/proxy/proxy-lifecycle.test.ts src/infra/net/proxy/proxy-validation.test.ts src/cli/proxy-cli.runtime.test.ts src/cli/proxy-cli.test.ts test/scripts/run-additional-boundary-checks.test.ts
  • pnpm lint:tmp:no-raw-http2-imports
  • scripts/run-opengrep.sh --error -- src/infra/net/http-connect-tunnel.ts src/infra/push-apns-http2.ts src/infra/push-apns.ts
  • pnpm exec oxfmt --check --threads=1 src/infra/net/http-connect-tunnel.ts src/infra/net/http-connect-tunnel.test.ts src/infra/push-apns.test.ts src/infra/net/proxy/active-proxy-state.ts docs/network.md CHANGELOG.md scripts/run-additional-boundary-checks.mjs test/scripts/run-additional-boundary-checks.test.ts
  • pnpm check:no-conflict-markers && git diff --check origin/main...HEAD && git merge-tree origin/main HEAD
  • OPENCLAW_LOCAL_CHECK=0 pnpm check:changed
  • Manual smoke with openclaw-proxy-lab: CONNECT to api.sandbox.push.apple.com:443, TLS ALPN h2, Node HTTP/2 session connected through proxy

Notes

  • Draft because this intentionally focuses on APNs HTTP/2 and the immediate managed-proxy lifecycle guardrails. Follow-ups for broader raw-socket policy remain separate.
  • APNs now follows active OpenClaw managed proxy state, not ambient HTTPS_PROXY/HTTP_PROXY discovery.
  • The custom tunnel supports http:// and https:// proxy endpoints and waits for the target TLS socket to negotiate h2 before handing it to HTTP/2.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Apr 30, 2026
@clawsweeper

clawsweeper Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

Summary
This PR routes direct APNs HTTP/2 sends through an APNs allowlisted managed-proxy CONNECT wrapper, adds APNs proxy validation/docs/guardrails, and expands regression and live-test coverage.

Reproducibility: yes. source-reproducible: current main sendApnsRequest() still uses raw http2.connect(authority) while managed proxy activation only covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Next step before merge
No repair job is needed; this automerge PR has no actionable review finding, so exact-head checks and merge gates are the remaining path.

Security
Cleared: Cleared: the diff narrows direct APNs egress through allowlisted CONNECT/TLS h2 handling, redacts proxy diagnostics, and I found no concrete supply-chain or workflow regression.

Review details

Best possible solution:

Land the exact reviewed head after required checks and automerge gates pass, while keeping broader raw socket classification in #77126.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: current main sendApnsRequest() still uses raw http2.connect(authority) while managed proxy activation only covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Is this the best way to solve the issue?

Yes. The reviewed head is a narrow maintainable fix for APNs HTTP/2: keep the existing send API, isolate raw HTTP/2 in one allowlisted wrapper, and leave broader raw socket policy to #77126.

What I checked:

Likely related people:

  • jesse-merhi: GitHub path history shows Jesse Merhi introduced the managed network proxy, added proxy validation, and recently maintained proxy lifecycle/TLS-hostname behavior; this PR also continues that same proxy surface beyond merely being authored by him. (role: proxy feature owner and recent maintainer; confidence: high; commits: 2633b1491413, 4ea0556f6428, 84a30e213e31; files: src/infra/net/proxy/proxy-lifecycle.ts, src/infra/net/proxy/proxy-validation.ts, docs/security/network-proxy.md)
  • steipete: GitHub path history shows Peter Steinberger repeatedly maintained push-apns.ts, proxy lifecycle, proxy validation, and network-proxy docs around the affected APNs and managed-proxy surfaces. (role: recent APNs/proxy maintainer and refactor owner; confidence: high; commits: 638437b7588d, 177654f526b2, bdcd543ed78a; files: src/infra/push-apns.ts, src/infra/net/proxy/proxy-lifecycle.ts, src/infra/net/proxy/proxy-validation.ts)
  • Mariano: GitHub path history shows the direct APNs wake/send surface in push-apns.ts traces back to the iOS/Gateway APNs wake work. (role: APNs wake feature introducer; confidence: medium; commits: e67da1538cfa; files: src/infra/push-apns.ts)
  • Nimrod Gutman: GitHub path history shows adjacent iOS APNs relay and approval notification work in the same APNs push file after the original wake surface landed. (role: adjacent iOS/APNs maintainer; confidence: medium; commits: b77b7485e0e1, 28955a36e7b0, 6f566585d84f; files: src/infra/push-apns.ts)

Remaining risk / open question:

  • The exact head still needs required CI/automerge gates because this read-only review did not execute tests and the diff touches security-sensitive proxy, workflow, and guardrail surfaces.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 5efbb3078a15.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts docs Improvements or additions to documentation security Security documentation size: L and removed scripts Repository scripts size: M labels Apr 30, 2026
@jesse-merhi jesse-merhi marked this pull request as ready for review April 30, 2026 11:11
@jesse-merhi jesse-merhi self-assigned this Apr 30, 2026
@jesse-merhi jesse-merhi force-pushed the apns-http2-proxy-pr branch 2 times, most recently from 1a92c5c to aadd7b9 Compare April 30, 2026 13:34
Copilot AI review requested due to automatic review settings May 1, 2026 02:38
@jesse-merhi jesse-merhi force-pushed the apns-http2-proxy-pr branch from aadd7b9 to 65b9950 Compare May 1, 2026 02:38
@jesse-merhi jesse-merhi force-pushed the apns-http2-proxy-pr branch from 65b9950 to 6bce235 Compare May 1, 2026 02:41

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.

Pull request overview

Routes direct APNs HTTP/2 delivery through OpenClaw’s managed proxy lifecycle by replacing the low-level APNs http2.connect() seam with a proxy-aware connection helper, and adds guardrails/tests to prevent future raw HTTP/2 usage that would bypass managed egress controls.

Changes:

  • Introduce connectApnsHttp2Session() to connect APNs HTTP/2 either directly or via a managed-proxy CONNECT tunnel (with APNs authority allowlisting).
  • Track active managed proxy URL/handle lifecycles centrally and enforce same-URL overlap semantics.
  • Add regression tests plus lint/OpenGrep rules to prevent new production raw node:http2 imports / http2.connect() usage.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/infra/push-apns.ts Switches APNs direct send path to use the new proxy-aware HTTP/2 session connector and shared cancel code constant.
src/infra/push-apns.test.ts Adds an end-to-end test that verifies direct APNs HTTP/2 traffic is routed through the active managed proxy using CONNECT.
src/infra/push-apns-http2.ts Adds the APNs HTTP/2 connection wrapper with authority allowlisting and managed-proxy integration.
src/infra/push-apns-http2.test.ts Unit tests for direct-vs-proxied session establishment, env proxy ignore behavior, and authority rejection.
src/infra/net/proxy/proxy-lifecycle.ts Integrates managed-proxy lifecycle with shared “active proxy state” tracking and overlap URL enforcement.
src/infra/net/proxy/proxy-lifecycle.test.ts Adds coverage for exposed active proxy URL, same-URL overlapping handles, and rejection of conflicting URL overlap.
src/infra/net/proxy/active-proxy-state.ts New module to track the single active managed proxy URL with handle-count lifecycle safety.
src/infra/net/http-connect-tunnel.ts New CONNECT + TLS tunnel helper used to route APNs sessions through the managed proxy.
src/infra/net/http-connect-tunnel.test.ts Unit tests for CONNECT request formatting, HTTPS proxy support, auth header behavior, and timeout handling.
security/opengrep/rules/openclaw-policy/no-raw-http2-connect.yml Adds a policy rule flagging raw http2.connect() usage outside the approved wrapper.
security/opengrep/precise.yml Updates compiled OpenGrep ruleset to include the new policy rule.
scripts/check-no-raw-http2-imports.mjs Adds a local lint script preventing production node:http2 imports outside the wrapper file.
package.json Wires in the new tmp lint check and includes it in the scripts lint pipeline.
docs/network.md Documents the policy to use connectApnsHttp2Session() for APNs HTTP/2 so managed proxy routing applies.
CHANGELOG.md Notes the behavior change: direct APNs HTTP/2 now honors managed proxy egress controls.

Comment thread src/infra/net/http-connect-tunnel.ts Outdated
Comment thread src/infra/net/http-connect-tunnel.ts Outdated
Comment thread src/infra/net/http-connect-tunnel.ts Outdated
Comment thread src/infra/push-apns-http2.ts Outdated
Comment thread src/infra/push-apns-http2.ts Outdated
Comment thread src/infra/push-apns.test.ts Outdated
@jesse-merhi jesse-merhi force-pushed the apns-http2-proxy-pr branch 5 times, most recently from ec5c471 to 64f48d5 Compare May 2, 2026 01:00
@jesse-merhi jesse-merhi requested a review from a team as a code owner May 2, 2026 01:00
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label May 2, 2026
@jesse-merhi jesse-merhi force-pushed the apns-http2-proxy-pr branch 2 times, most recently from 1127b62 to c67415e Compare May 2, 2026 01:04
@clawsweeper clawsweeper Bot force-pushed the apns-http2-proxy-pr branch from 4521f70 to dab7c86 Compare May 4, 2026 10:55
@openclaw-barnacle openclaw-barnacle Bot removed the agents Agent runtime and tooling label May 4, 2026
@clawsweeper clawsweeper Bot merged commit d5b0083 into main May 4, 2026
96 of 97 checks passed
@clawsweeper clawsweeper Bot deleted the apns-http2-proxy-pr branch May 4, 2026 11:04
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
Summary:
- This PR routes direct APNs HTTP/2 sends through an APNs allowlisted managed-proxy CONNECT wrapper, adds APNs proxy validation/docs/guardrails, and expands regression and live-test coverage.
- Reproducibility: yes. source-reproducible: current main `sendApnsRequest()` still uses raw `http2.connect(au ... nly covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 APNs connections
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 with OpenGrep
- PR branch already contained follow-up commit before automerge: lint: ban raw HTTP2 imports
- PR branch already contained follow-up commit before automerge: fix: use managed proxy state for APNs
- PR branch already contained follow-up commit before automerge: test: exercise APNs active proxy state
- PR branch already contained follow-up commit before automerge: fix: reject conflicting managed proxy activation

Validation:
- ClawSweeper review passed for head dab7c86.
- Required merge gates passed before the squash merge.

Prepared head SHA: dab7c86
Review: openclaw#74905 (comment)

Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Summary:
- This PR routes direct APNs HTTP/2 sends through an APNs allowlisted managed-proxy CONNECT wrapper, adds APNs proxy validation/docs/guardrails, and expands regression and live-test coverage.
- Reproducibility: yes. source-reproducible: current main `sendApnsRequest()` still uses raw `http2.connect(au ... nly covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 APNs connections
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 with OpenGrep
- PR branch already contained follow-up commit before automerge: lint: ban raw HTTP2 imports
- PR branch already contained follow-up commit before automerge: fix: use managed proxy state for APNs
- PR branch already contained follow-up commit before automerge: test: exercise APNs active proxy state
- PR branch already contained follow-up commit before automerge: fix: reject conflicting managed proxy activation

Validation:
- ClawSweeper review passed for head dab7c86.
- Required merge gates passed before the squash merge.

Prepared head SHA: dab7c86
Review: openclaw#74905 (comment)

Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
greench-ai pushed a commit to greench-ai/nexisclaw that referenced this pull request May 12, 2026
Summary:
- This PR routes direct APNs HTTP/2 sends through an APNs allowlisted managed-proxy CONNECT wrapper, adds APNs proxy validation/docs/guardrails, and expands regression and live-test coverage.
- Reproducibility: yes. source-reproducible: current main `sendApnsRequest()` still uses raw `http2.connect(au ... nly covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 APNs connections
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 with OpenGrep
- PR branch already contained follow-up commit before automerge: lint: ban raw HTTP2 imports
- PR branch already contained follow-up commit before automerge: fix: use managed proxy state for APNs
- PR branch already contained follow-up commit before automerge: test: exercise APNs active proxy state
- PR branch already contained follow-up commit before automerge: fix: reject conflicting managed proxy activation

Validation:
- ClawSweeper review passed for head dab7c86a7595a01b09c32395578e7c26a03f938d.
- Required merge gates passed before the squash merge.

Prepared head SHA: dab7c86a7595a01b09c32395578e7c26a03f938d
Review: openclaw/openclaw#74905 (comment)

Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
markfietje pushed a commit to markfietje/openclaw that referenced this pull request May 20, 2026
Summary:
- This PR routes direct APNs HTTP/2 sends through an APNs allowlisted managed-proxy CONNECT wrapper, adds APNs proxy validation/docs/guardrails, and expands regression and live-test coverage.
- Reproducibility: yes. source-reproducible: current main `sendApnsRequest()` still uses raw `http2.connect(au ... nly covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 APNs connections
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 with OpenGrep
- PR branch already contained follow-up commit before automerge: lint: ban raw HTTP2 imports
- PR branch already contained follow-up commit before automerge: fix: use managed proxy state for APNs
- PR branch already contained follow-up commit before automerge: test: exercise APNs active proxy state
- PR branch already contained follow-up commit before automerge: fix: reject conflicting managed proxy activation

Validation:
- ClawSweeper review passed for head dab7c86a7595a01b09c32395578e7c26a03f938d.
- Required merge gates passed before the squash merge.

Prepared head SHA: dab7c86a7595a01b09c32395578e7c26a03f938d
Review: openclaw/openclaw#74905 (comment)

Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
markfietje pushed a commit to markfietje/openclaw that referenced this pull request May 20, 2026
Summary:
- This PR routes direct APNs HTTP/2 sends through an APNs allowlisted managed-proxy CONNECT wrapper, adds APNs proxy validation/docs/guardrails, and expands regression and live-test coverage.
- Reproducibility: yes. source-reproducible: current main `sendApnsRequest()` still uses raw `http2.connect(au ... nly covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 APNs connections
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 with OpenGrep
- PR branch already contained follow-up commit before automerge: lint: ban raw HTTP2 imports
- PR branch already contained follow-up commit before automerge: fix: use managed proxy state for APNs
- PR branch already contained follow-up commit before automerge: test: exercise APNs active proxy state
- PR branch already contained follow-up commit before automerge: fix: reject conflicting managed proxy activation

Validation:
- ClawSweeper review passed for head dab7c86a7595a01b09c32395578e7c26a03f938d.
- Required merge gates passed before the squash merge.

Prepared head SHA: dab7c86a7595a01b09c32395578e7c26a03f938d
Review: openclaw/openclaw#74905 (comment)

Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Summary:
- This PR routes direct APNs HTTP/2 sends through an APNs allowlisted managed-proxy CONNECT wrapper, adds APNs proxy validation/docs/guardrails, and expands regression and live-test coverage.
- Reproducibility: yes. source-reproducible: current main `sendApnsRequest()` still uses raw `http2.connect(au ... nly covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 APNs connections
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 with OpenGrep
- PR branch already contained follow-up commit before automerge: lint: ban raw HTTP2 imports
- PR branch already contained follow-up commit before automerge: fix: use managed proxy state for APNs
- PR branch already contained follow-up commit before automerge: test: exercise APNs active proxy state
- PR branch already contained follow-up commit before automerge: fix: reject conflicting managed proxy activation

Validation:
- ClawSweeper review passed for head dab7c86.
- Required merge gates passed before the squash merge.

Prepared head SHA: dab7c86
Review: openclaw#74905 (comment)

Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Summary:
- This PR routes direct APNs HTTP/2 sends through an APNs allowlisted managed-proxy CONNECT wrapper, adds APNs proxy validation/docs/guardrails, and expands regression and live-test coverage.
- Reproducibility: yes. source-reproducible: current main `sendApnsRequest()` still uses raw `http2.connect(au ... nly covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 APNs connections
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 with OpenGrep
- PR branch already contained follow-up commit before automerge: lint: ban raw HTTP2 imports
- PR branch already contained follow-up commit before automerge: fix: use managed proxy state for APNs
- PR branch already contained follow-up commit before automerge: test: exercise APNs active proxy state
- PR branch already contained follow-up commit before automerge: fix: reject conflicting managed proxy activation

Validation:
- ClawSweeper review passed for head dab7c86.
- Required merge gates passed before the squash merge.

Prepared head SHA: dab7c86
Review: openclaw#74905 (comment)

Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Summary:
- This PR routes direct APNs HTTP/2 sends through an APNs allowlisted managed-proxy CONNECT wrapper, adds APNs proxy validation/docs/guardrails, and expands regression and live-test coverage.
- Reproducibility: yes. source-reproducible: current main `sendApnsRequest()` still uses raw `http2.connect(au ... nly covers HTTP/global-agent/Undici hooks. I did not run a live APNs reproduction in this read-only review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 APNs connections
- PR branch already contained follow-up commit before automerge: test: guard raw HTTP2 with OpenGrep
- PR branch already contained follow-up commit before automerge: lint: ban raw HTTP2 imports
- PR branch already contained follow-up commit before automerge: fix: use managed proxy state for APNs
- PR branch already contained follow-up commit before automerge: test: exercise APNs active proxy state
- PR branch already contained follow-up commit before automerge: fix: reject conflicting managed proxy activation

Validation:
- ClawSweeper review passed for head dab7c86.
- Required merge gates passed before the squash merge.

Prepared head SHA: dab7c86
Review: openclaw#74905 (comment)

Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR scripts Repository scripts security Security documentation size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants