Skip to content

fix(irc): disconnect on oversized inbound lines - #107376

Closed
ZengWen-DT wants to merge 1 commit into
openclaw:mainfrom
ZengWen-DT:agent/fix-irc-oversized-inbound-lines
Closed

ZengWen-DT wants to merge 1 commit into
openclaw:mainfrom
ZengWen-DT:agent/fix-irc-oversized-inbound-lines

Conversation

@ZengWen-DT

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a broken or hostile IRC server could keep sending an unterminated line and make OpenClaw retain the growing input indefinitely while the channel remained connected.

Why This Change Was Made

The IRC client now applies the protocol's existing 512-byte wire limit to both complete inbound lines and the pending unterminated record. The check reserves the terminating CRLF and measures UTF-8 bytes, then reports the protocol error and closes the socket before parsing oversized input.

User Impact

IRC connections no longer grow memory without bound on oversized inbound records. Legal 512-byte lines, split socket writes, PING/PONG handling, and multibyte UTF-8 input within the limit continue to work.

Evidence

  • Real Linux TCP loopback server/client regression: a post-registration 1 MiB fragment without CRLF produced exactly IRC inbound line exceeds the 512-byte limit, closed the socket, and made the client not ready.
  • Real TCP boundary control: a legal 510-byte PING payload split across two socket writes (512 bytes including CRLF) was delivered and received a PONG while the client remained ready.
  • UTF-8 control: an oversized multibyte line was rejected by byte length rather than JavaScript character count.
  • node scripts/run-vitest.mjs extensions/irc/src/client.test.ts — 19 passed.
  • node scripts/run-vitest.mjs extensions/irc/src/client.surrogate.test.ts — 5 passed.
  • .agents/skills/autoreview/scripts/autoreview --mode local — clean, no accepted/actionable findings.
  • git diff --check — passed.

Remote Testbox evidence was not available in the authoring environment because neither Crabbox nor Blacksmith was installed; the socket evidence above uses real kernel TCP sockets rather than mocked transports.

AI-assisted: implemented and reviewed with Codex; I reviewed the resulting code and validation evidence.

@ZengWen-DT
ZengWen-DT marked this pull request as ready for review July 14, 2026 10:46
@ZengWen-DT
ZengWen-DT force-pushed the agent/fix-irc-oversized-inbound-lines branch 2 times, most recently from 4191461 to 3c38ba7 Compare July 14, 2026 12:35
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 14, 2026
@clawsweeper

clawsweeper Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 15, 2026, 10:14 PM ET / July 16, 2026, 02:14 UTC.

Summary
Adds a 512-byte UTF-8 limit for complete and pending inbound IRC records, closes the socket on violations, and adds real TCP boundary, fragmentation, and multibyte regression coverage.

PR surface: Source +13, Tests +103. Total +116 across 2 files.

Reproducibility: yes. from source, with high confidence: current main retains an unterminated record without a byte bound, and the PR's real TCP scenario demonstrates the corrected path. A separate account-level recovery reproduction remains missing.

Review metrics: 1 noteworthy metric.

  • Fail-closed protocol conditions: 1 added. The PR adds a new runtime condition that deliberately tears down an established IRC connection, so account-level upgrade behavior matters before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Obtain IRC-owner confirmation and account-level proof for the intended post-disconnect recovery behavior.
  • Rebase onto current main and refresh the focused IRC review on the resulting head.

Risk before merge

  • [P1] An IRC server that emits one oversized record will now force the account socket offline; the evidence does not show whether the surrounding monitor reconnects with bounded backoff, remains terminally offline, or clearly exposes operator recovery.
  • [P0] Repeated oversized records could become either a persistent channel outage or a reconnect loop depending on account-monitor behavior, and green client-level tests do not settle that lifecycle choice.
  • [P1] The PR head is behind current main, so the final merged head still needs a focused IRC review refresh after rebasing.

Maintainer options:

  1. Prove bounded account recovery (recommended)
    Extend the proof through the IRC account monitor and demonstrate bounded reconnection or a deliberate terminal state before merge.
  2. Land the fail-closed outage policy
    Accept that one oversized server record can take the IRC account offline, with explicit IRC-owner approval and a visible operator recovery path.
  3. Pause until lifecycle ownership is clear
    Leave the PR open without merging if neither reconnect nor terminal-offline behavior is currently an accepted IRC contract.

Next step before merge

  • [P2] An IRC owner should choose and verify the account-level recovery contract after the deliberate socket close; no narrow mechanical patch defect remains for an automated repair lane.

Maintainer decision needed

  • Question: After an oversized inbound IRC record closes the socket, should the account automatically reconnect with bounded backoff, or intentionally remain offline until operator recovery?
  • Rationale: Both behaviors are plausible operational policies, but the client-only patch and proof do not establish which lifecycle the IRC channel promises after a protocol violation.
  • Likely owner: vignesh07 — The repository explicitly assigns IRC ownership to this account, making it the best available owner for the disconnect and recovery policy.
  • Options:
    • Prove bounded recovery (recommended): Add account-level coverage showing that the monitor reconnects safely with bounded backoff and cannot enter a tight hostile-server loop.
    • Accept terminal disconnect: Land the fail-closed behavior only after confirming that remaining offline is intentional and that status or logs provide a clear operator recovery path.
    • Pause pending IRC policy: Hold the PR until the IRC owner chooses the permanent post-violation lifecycle contract.

Security
Cleared: The patch bounds attacker-controlled network input without adding dependencies, permissions, secrets access, downloaded code, or supply-chain changes.

Review details

Best possible solution:

Keep the byte-bounded fail-closed parser, but add an IRC-owner-approved account-level contract and regression proof showing either bounded reconnect/backoff or a clearly reported terminal offline state with an explicit recovery path.

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

Yes from source, with high confidence: current main retains an unterminated record without a byte bound, and the PR's real TCP scenario demonstrates the corrected path. A separate account-level recovery reproduction remains missing.

Is this the best way to solve the issue?

Yes for bounding hostile input at the IRC client boundary; disconnecting before parsing is narrow and protocol-consistent. The solution is incomplete as a merge decision until the account monitor's post-disconnect behavior is explicitly chosen and proven.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d42dfed3f256.

Label changes

Label justifications:

  • P2: This is a focused IRC resource-exhaustion fix with limited channel scope and strong proof, but it needs ordinary owner review for the resulting disconnect lifecycle.
  • merge-risk: 🚨 compatibility: Existing IRC setups that previously tolerated or parsed oversized server records will instead have their established socket closed after merge.
  • merge-risk: 🚨 availability: The new fail-closed branch can take an IRC account offline, while the surrounding reconnect or operator-recovery behavior remains unproven.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides convincing after-fix real TCP loopback evidence for oversized input rejection, socket closure, legal boundary traffic, PING/PONG continuity, and UTF-8 byte handling; account-monitor recovery remains a product-risk question rather than a contributor proof failure.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides convincing after-fix real TCP loopback evidence for oversized input rejection, socket closure, legal boundary traffic, PING/PONG continuity, and UTF-8 byte handling; account-monitor recovery remains a product-risk question rather than a contributor proof failure.
Evidence reviewed

PR surface:

Source +13, Tests +103. Total +116 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 0 +13
Tests 1 103 0 +103
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 116 0 +116

What I checked:

  • Inbound limit implementation: The patch reserves two bytes for CRLF, measures complete and pending records with UTF-8 byte length, reports a protocol error, and closes the socket before parsing oversized input. (extensions/irc/src/client.ts:293, 7e740ba53635)
  • Unbounded current-main path: The current main implementation lacks the proposed pending-record byte bound, so an unterminated inbound record can continue growing in the retained client buffer. (extensions/irc/src/client.ts:415, d42dfed3f256)
  • Real behavior proof: The PR reports real Linux loopback TCP proof for a 1 MiB unterminated record, a legal 512-byte split PING/PONG exchange, socket closure, readiness transition, and UTF-8 byte measurement; focused IRC tests and CI also pass. (extensions/irc/src/client.test.ts:279, 7e740ba53635)
  • Protocol contract: The IRC client protocol specification describes the common 512-byte limit including CRLF and permits closing the connection for oversized messages, while noting that disconnecting can be confusing to users. (modern.ircdocs.horse)
  • Owner routing: The repository contribution guide explicitly assigns IRC ownership to @vignesh07, who was also mentioned in this PR timeline. (github.com) (CONTRIBUTING.md, d42dfed3f256)
  • Review continuity: The current head is identical to the latest reviewed SHA; twelve completed ClawSweeper cycles reported no code findings and consistently left only the post-disconnect recovery contract for owner review. (7e740ba53635)

Likely related people:

  • vignesh07: The repository's contributor guide explicitly lists Vignesh for IRC ownership, and the PR timeline routes this change to that account for review. (role: IRC feature owner; confidence: high; files: extensions/irc/src/client.ts, extensions/irc/src/client.test.ts, extensions/irc/src/monitor.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-14T16:08:05.654Z sha 58c2f8c8ae4a0182dbc0353c40b59a18b79399db :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T16:55:05.388Z sha 58c2f8c8ae4a0182dbc0353c40b59a18b79399db :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T17:26:35.943Z sha 58c2f8c8ae4a0182dbc0353c40b59a18b79399db :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T17:58:20.600Z sha 58c2f8c8ae4a0182dbc0353c40b59a18b79399db :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T18:57:10.109Z sha 58c2f8c8ae4a0182dbc0353c40b59a18b79399db :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T19:26:40.825Z sha 58c2f8c8ae4a0182dbc0353c40b59a18b79399db :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T19:54:36.676Z sha 58c2f8c8ae4a0182dbc0353c40b59a18b79399db :: needs maintainer review before merge. :: none
  • reviewed 2026-07-15T11:10:06.995Z sha 7e740ba :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Jul 14, 2026
@ZengWen-DT
ZengWen-DT force-pushed the agent/fix-irc-oversized-inbound-lines branch 2 times, most recently from 58c2f8c to 1270c76 Compare July 14, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: irc merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant