Skip to content

Add defensive behavior for strict environments like sandboxes - #411

Open
bjester wants to merge 5 commits into
scope-filter-orderingfrom
sandboxing-defense
Open

bjester wants to merge 5 commits into
scope-filter-orderingfrom
sandboxing-defense

Conversation

@bjester

@bjester bjester commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Updates _get_client_ip_for_server to be more tolerant of sandboxing by handling specific socket establishment errors separately from connection errors to retrieve the address
  • Updates test utility get_free_tcp_port to be tolerant of failures using port 0 for automatic free port assignment
  • Updates test test_consistent_0_5_instance_id to override environment variables since the test must assert that MORANGO_NODE_ID does not influence the resulting ID

Reviewer guidance

  • Do tests run locally?
  • Do tests pass when you ask an agent to run them, with network filtering using nono?

Necessary config for ports

  "network": {
    "allow_domain": [
      "127.0.0.1",
    ],
    "open_port": [
      3000,
      8000,
      8001,
      8080,
      8081,
      8888,
      10001,
      10002,
      10003
    ]
  }

AI usage

Claude and I debugged these issues within my sandboxed agent session using nono, while working on #410 . Most of the changes were clear to me, so I made them initially, then let Claude ensure that the changes were robust. Then had Claude handle the review feedback, which we should have caught earlier.

@bjester
bjester added this pull request to stack #412 November 2, 2026 14:55
@bjester
bjester force-pushed the sandboxing-defense branch 2 times, most recently from e660f7f to de4c5fc Compare November 2, 2026 18:09
@bjester
bjester force-pushed the sandboxing-defense branch from de4c5fc to 605afdb Compare November 2, 2026 23:37
@bjester
bjester force-pushed the sandboxing-defense branch from 605afdb to 92c564b Compare November 3, 2026 21:58
bjester and others added 3 commits November 5, 2026 11:24
_get_client_ip_for_server opens a UDP socket to learn which local
address routes to the server. AppArmor or a sandbox can refuse to
create that socket, which raised outside the existing try block. It
now logs a warning and returns 127.0.0.1, as it already did when the
connect failed. The bare except is narrowed to OSError.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A MORANGO_NODE_ID set in the environment overrides the node ID, so
test_consistent_0_5_instance_id got a different instance ID than the
one it expects.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A sandbox can deny binding to port 0, which LiveServerTestCase uses by
default and get_free_tcp_port used to find a free port.
get_free_tcp_port moves to the test helpers and falls back to a fixed
list of ports when port 0 is denied. A new FreePortLiveServerTestCase
picks its port with it in setUpClass, so each class gets a port that
is free when its server starts. The client test cases now extend it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@bjester
bjester force-pushed the sandboxing-defense branch from 92c564b to 9cc2ca5 Compare November 5, 2026 19:25
@bjester
bjester marked this pull request as ready for review November 5, 2026 19:30
@bjester
bjester requested review from a team, leq-bot and rtibblesbot November 5, 2026 19:30
@rtibblesbot

rtibblesbot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Waiting for changes

Outcome: skipped — no new commits since 871db23

Last updated: 2026-11-06 00:39 UTC

@rtibblesbot rtibblesbot 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.

PR #411: the narrowed IP-probe fallback and explicit live-server ports look correct. CI is passing.

  • suggestion: the two new fallback branches in _get_client_ip_for_server have no tests (inline).
  • nitpick: get_free_tcp_port leaks a socket per failed bind (inline).

Next step: This is a low-risk change; it needs a light-touch code review by a human engineer.


Written by rtibblesbot, an LLM-based coding agent.

Comment thread morango/sync/syncsession.py Resolved
Comment thread tests/testapp/tests/helpers.py Resolved
bjester and others added 2 commits November 5, 2026 16:15
The socket was only closed after a successful bind, so each port the
sandbox refused left a socket open until garbage collection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers both paths that return 127.0.0.1: when the UDP socket can't be
created, and when connect raises OSError, UnicodeError or
OverflowError. The second also checks that the socket is closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@rtibblesbot rtibblesbot 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.

PR #411: both prior findings resolved. No new findings. CI still pending.

Prior-finding status

RESOLVED — morango/sync/syncsession.py:71 — no test covers _get_client_ip_for_server fallbacks
RESOLVED — tests/testapp/tests/helpers.py — failed bind leaks open socket

Next step: Needs a full code review by a human engineer.

  • Confirm falling back to 127.0.0.1 in _get_client_ip_for_server when the probe is denied is acceptable for real sync sessions, not just sandboxed tests.

Written by rtibblesbot, an LLM-based coding agent.

@bjester
bjester removed this pull request from stack #412 November 7, 2026 00:24
@bjester
bjester added this pull request to stack #418 November 7, 2026 00:24
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